insert into table b select * from table a (nolock)
Where do I put the nolock? The above is giving an error as invalid column name ‘nolock’
My requirement is to insert the data from table a to table b but I am getting frequent deadlocks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Assuming this is for SQL Server…
A more modern way to write it would be
There are many risks and consequences from using this. Worth considering whether table a will always deliver consistent results when using
readuncommitted, the more recent version ofNOLOCKS.Even with this you can still see a deadlock, depending on what else is happening to those tables at the time. You eliminate one potential cause of deadlocks by reading uncommitted data and holding no locks on table a as you read.
See this question for some details:
Is nolock (SQL Server) hint bad practice?