Friday, February 24, 2012
Can i tell if Procedure is running
Hi, is there a way to know if a procedure is running or not? what i'm trying to accomplish is to automate the merge of tables but only one table at the time can be merge. so i'm thinking that if i have a way of knowing if the merge procedure is running then i could run it only when it's not alreay run it. hope does make sense. thanks.Rather than trying to tell if a particular piece of code is running, which would be shaky at best, create a table in the database - it can be very simple, one column, which is a flag to indicate if the proc is running. When the proc runs have it check the flag, back out if already running, otherwise set the flag, run the merge, and when its done reset the flag.|||Instead of trying to figure if the SP is running or not, use application locks to serialize execution of the SP. Look at sp_getapplock and sp_getreleaselock. You can use it from SQL Server 2000 onwards.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment