May 2007 Entries

SQL Server Gotcha

In SQL Server T-SQL, you can follow a table name with a table hint. The formal syntax is: WITH (table hint) But, for backward compatibility reasons, WITH is optional. So, these are equivalent: select * from Person.Contact with (nolock); select * from Person.Contact (nolock); But, what does this do? select * from Person.Contact nolock; Most likely, not what you want. This query aliases Person.Contact as nolock. Unlike the first 2 queries, it will obtain a shared lock on all the data it touches. This...