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.
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.
Assuming this is for SQL Server...
A more modern way to write it would be
insert into b
select *
from a with (readuncomitted)
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 of NOLOCKS
.
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: