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)
 Check Who Is Accessing The Table

Author  Topic 

Beginer2012
Starting Member

45 Posts

Posted - 2012-07-17 : 14:52:30
Hello,
I'm writing a procedure and I would like to check if any user is currently using or selecting from a table before I lock and update the table.
How can I check if the table is in use ? What I need if the table is is being accessed by another user before updating the table

Thank you

X002548
Not Just a Number

15586 Posts

Posted - 2012-07-17 : 15:25:57
It's not a Sole possession of a thing

You are modifying rows of data, or getting rows of data

Every table I create as 4 columns.

Who added a row
When it was added
Who updated a row
When it was updated

Some people don't care and just update rows and potentially overlay previous changes

I usually select data and display it...I carry the update datetime with me

When I go back to do an update, I check to make sure the datetime is exactly the same along with the key

If it's not, I let them know the data has been modified sine you last grabbed...and maybe show what the changes write

Then let them decide what to do

Without a better understanding of what you are trying to do, we can't help you
Go to Top of Page

Beginer2012
Starting Member

45 Posts

Posted - 2012-07-25 : 13:53:36
Thank you for the help !!!!!!!
quote:
Originally posted by Beginer2012

Hello,
I'm writing a procedure and I would like to check if any user is currently using or selecting from a table before I lock and update the table.
How can I check if the table is in use ? What I need if the table is is being accessed by another user before updating the table

Thank you

Go to Top of Page
   

- Advertisement -