July 22, 2009 at 11:48 pm
Hi All,
How do i check whether the table is in use. i need to check if the table is in use, i need to restrict the other user not allowing to update/delete.
is there a way to which returns a value so that based upon the value i can disable update in the front end
Thanks
Shankar.N
July 23, 2009 at 7:58 pm
SQL Server exercises it's own locking. Why do you want to override it?
--Jeff Moden
Change is inevitable... Change for the better is not.
July 24, 2009 at 7:55 am
Use this:
SELECT top 1 *
FROM dbo.sysobjects o, master.dbo.syslockinfo l
WHERE l.rsc_objid = o.id
AND name = ''
an locked object will be in syslockinfo table, you can select data to check this before you going to have some heavy operations.
Enjoy !!
July 24, 2009 at 8:16 am
If you just want to guarantee exclusive use for a heavy operation, you don't need to do that. Just use the WITH(TABLOCKX) hint and when it's able, it'll lock the table for exclusive use.
--Jeff Moden
Change is inevitable... Change for the better is not.
July 24, 2009 at 8:20 am
You don't need to check if a table is in use. As Jeff mentioned, SQL Server handles this.
If you do want to manually lock a table/row for some reason, you would use a separate column or table and mark a value that your application will check.
If you think you do need to check, I'd suggest you give us reasons why so we can help you determine the best way to do this.
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply