Thursday, January 8, 2009

@_variable_in

When declaring input variables to a stored procedure in MS SQL Server, it is sometimes beneficial to use

@_variable_in instead of @variable_in

WITH (NOLOCK)

Using the NOLOCK hint can speed up queries by allowing the query to not wait while other queries are writing to the table. The downside is that your query can read data that may get rolled back.

FROM table1 a WITH (NOLOCK)
JOIN table 2 b WITH (NOLOCK) ON a.field = b.field
JOIN table3 c WITH (NOLOCK) ON b.field= c.field
JOIN table4e WITH (NOLOCK)


More info: http://msdn.microsoft.com/en-us/library/ms187373.aspx