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)
 sql lock

Author  Topic 

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2015-01-26 : 05:20:36
Hello,
User1 runs a program which does alot of insert into table1 from views...

user2 at the same time as User1 tries to run select * from table1 but User2 does not get any data because table1 seems to be locked by User1.

Is there a special sql I can use to avoid this?

Thanks

sz1
Aged Yak Warrior

555 Posts

Posted - 2015-01-26 : 09:02:00
Have you looked at NOLOCK, WITH (NOLOCK) is the equivalent of using READ UNCOMMITED so it can be bad for dirty reads, it depends what you are trying to achieve.it should be used carefully if at all.

We are the creators of our own reality!
Go to Top of Page

viggneshwar
Yak Posting Veteran

86 Posts

Posted - 2015-01-28 : 03:17:30
NOLOCK will return the uncommited records too. So decide as per your business requirement and then use the nolock.

Regards
Viggneshwar A
Go to Top of Page
   

- Advertisement -