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 2012 Forums
 Transact-SQL (2012)
 Row locking

Author  Topic 

sangamd
Starting Member

2 Posts

Posted - 2014-05-27 : 06:00:03

Have one table :
----------------------
ID EMPNAME SAL
----------------------
112 John 15000
113 Sid 25000
114 Smeeth 18000
115 Roy 26000
116 Robort 50000


Users :
UserOne and UserTwo


I want to achieve row locking on above table, like if userone accessing row having id 114 during this if usertwo want to select * from table then usertwo can get only rows having no lock (other than row having id 114).
is this possible ?
if yes then please help me...

Thanks

Sangam

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2014-05-27 : 11:43:14
It is not possible unless you do some form of custom "locking."
Go to Top of Page

sangamd
Starting Member

2 Posts

Posted - 2014-05-28 : 02:11:21
custom "locking."?
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2014-05-28 : 11:54:10
Another term for that is Optimistic Concurrency. Basically, you need some column or columns that are used as a in indicator that the row is being edited. Then you can exclude that row from your query for a different user.

Here is an MSDN article about the topic:
http://msdn.microsoft.com/en-us/library/aa0416cz.aspx

Go to Top of Page
   

- Advertisement -