Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Rename table

Author  Topic 

juicyapple
Posting Yak Master

176 Posts

Posted - 2008-02-25 : 02:25:37
Hi, I have written a service to rename table, how to check is the table is locked by another processes? There are some processes will execute select statement on it. The rename transaction must wait until all the select transactions have been finished.

Thanks.

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2008-02-25 : 14:23:59
Try check with sp_locks.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-02-26 : 01:51:45
quote:
Originally posted by rmiao

Try check with sp_locks.


Did you mean sp_lock?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

juicyapple
Posting Yak Master

176 Posts

Posted - 2008-02-27 : 23:19:02
what is the objid returned in sp_lock?? how do I 'convert' it to string value?
Go to Top of Page

dataguru1971
Master Smack Fu Yak Hacker

1464 Posts

Posted - 2008-02-27 : 23:39:10
You can find out the desired table's ID by

Select OBJECT_ID([tablename])

Then refer to that object ID in your check.

OR

OBJECT_NAME([ID]) funtion will convert to string for you.

Check books-on-line in the help menu, faster than a forum



Poor planning on your part does not constitute an emergency on my part.

Go to Top of Page

juicyapple
Posting Yak Master

176 Posts

Posted - 2008-02-29 : 03:28:18
Hi, with using sp_lock, I can check all the objects locked by any of the client application or store procedure call (static sql or dinamic sql), locally and remotely?
Go to Top of Page
   

- Advertisement -