SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Transaction with no read lock
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Kimi86
Yak Posting Veteran

79 Posts

Posted - 08/20/2014 :  13:13:45  Show Profile  Reply with Quote
I have a code that does something like below

Begin transaction

Insert into Table A
Select * from Table 8

Commit Transaction

Now during the time the insert takes place the tables get lock and cant be even read..
Is there a way to be able to at least read the data in table B when the query is running


Thanks

tkizer
Almighty SQL Goddess

USA
37129 Posts

Posted - 08/20/2014 :  13:45:57  Show Profile  Visit tkizer's Homepage  Reply with Quote
You should look into RCSI isolation level. You could use the nolock hint, however the insert/select could get bad data due to the dirty reads.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/

Edited by - tkizer on 08/20/2014 13:46:16
Go to Top of Page

Kimi86
Yak Posting Veteran

79 Posts

Posted - 08/20/2014 :  15:08:49  Show Profile  Reply with Quote
There is no process that could read or write into Table A during the transaction . Also there could be no process that could write data into Table B during the transaction. I could only have reads for table B while transaction runs.. Also I cannot go and change the read process because and apply nowait there.. So is there a way i could run this transaction in a way that the read on table B remains unlocked
Go to Top of Page

tkizer
Almighty SQL Goddess

USA
37129 Posts

Posted - 08/20/2014 :  15:37:42  Show Profile  Visit tkizer's Homepage  Reply with Quote
Use the nolock hint on TableB for your insert/select.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000