SQL Server Query Taking Too Long Handling?
I have a complex query inside a stored proc. Within the proc itself, I would like to judge how long things are taking and do a RAISERROR if I think a 30-second threshhold has been passed (which will force people to do some optimizations).开发者_如何学运维
Can anyone say a decent way to make that happen, all within TSQL code?
Thanks.
You could issue a set query_governor_cost_limit
before commencing on the potentially costly query. However, I believe that this cancels the query before it starts (if it's estimated to take too long), rather than cancelling it when the limit is actually reached.
精彩评论