Doing selects over database tables even when they are in a transaction

by andrei 20. November 2008 06:36

Did this ever happen to you?

 

You are debugging, and you are in a transaction, and you want to check something in one of the tables. You try a select:

select * from Something

but it does not work: it will freeze because it's waiting for the transaction to end.

 

Here is the solution:

select * from Something with(nolock)

 

This will tell SQL Server that you are not interested in participating in the locking contest, and it will give you the information even if the transaction has a lock over that table.

 

 

Enjoy programming!

 

I am putting together a set of concept lists for the main programming techniques, which should help developers learning or using them to be more efficient. Here are the techniques in progress:

Please feel free to leave any comments or suggestions which could make these lists more useful for everyone.

 

 

Also, if you are interested in learning these techniques you can try the developer training modules.

Again, please feel free to leave any comments or suggestions which could make the training modules more useful for everyone. We are having great results with them at Akcedo (so they really work), but they can always be improved. Also, if you would like to use the modules or are already using them and you want to discuss about the process feel free to comment and ask questions here.

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading



Powered by BlogEngine.NET 1.4.5.0