-3
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.

Gouse
  • 57
  • 1
  • 8
  • 1
    It was also quite bad spelling and formatting. Please use proper capitalization at least. – Corbin Apr 28 '12 at 10:02
  • 2
    Clustering is a completely separate question? Also, have you considered googling for the syntax of nolock? To be blunt, not even bothering to google for the syntax shows an abhorrent laziness in trying to figure out your problem. – Corbin Apr 28 '12 at 10:04
  • sorry Corbin i made search in google then i found that above query which is not working so i posted here – Gouse Apr 28 '12 at 10:06

1 Answers1

2

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:

Is nolock (SQL Server) hint bad practice?

Community
  • 1
  • 1
joshp
  • 1,886
  • 2
  • 20
  • 28