Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 3570

utcgetdate - stop a query after x time

$
0
0

Hi

 

Im looking for a way to stop a query after a given period of time or a specific timestamp, like

 

select * from bigtable where getutcdate() < "2015-06-19 15:00:00"

 

 

In Sybooks, the utcgetdate function mentions that :

 

Returns a date and time where the value is in Universal Coordinated Time (UTC). getutcdate is calculated each time a row is inserted or selected.

 

 

But, when running the following command, even for a long time, the timestamp value doesn't change at all...  not even microseconds. Looks like it get cached 

 

select top 50000 convert(char(26),getutcdate(),109),* from bigtable

 

 

I can guess that this may incur a reasonable overhead since time function may requet a spinlock to get the clock value, so , i was planning to wrap up this time check in a function and pass a number (probably the sequential numeric key at hand)  and get the modulus of this number by 1000

 

The idea is also only use this construction on very specific queries which may be triggered by the end of the day and the results expected on the next day, but they should not get into business hours....

 

Someone have some ideas to share?

 

Thanks!


Viewing all articles
Browse latest Browse all 3570

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>