E-Mail:
Author Avatar

Using SQL Server Reserved Words

Hello again… I hope you had a good holiday weekend for those of you who had the holiday off. Last night I came across a stored procedure that used SQL Server reserved words in the SELECT and INSERT statements. Since I am using SQL Server 2005, the words that came up as “reserved” were:
status
views
subject
user_id

If you must use SQL Server reserved words put brackets [] around them. Putting reserved words in brackets [] is a “tuning” technique that DBAs use to “optimize” T-SQL code. If you do NOT put brackets [] around the reserved words then SQL Server will need to take the time to “resolve” the word and decide if it is being used as a reserved word or if it corresponds to a column in a user table or a literal in a result set. This will take SQL Server longer to execute the T-SQL script. If the reserved words do in fact have brackets [] then SQL Server knows that it corresponds to a column name or as a literal if you use it as a column heading in a result set and will not have to do a compare.

I hope this helps you out… if you have any other way to tune or optimize please comment!

What Do You Think?

 


Anti-Spam Image

Want to Start a Blog Here for Free?

Are you an expert in one subject or another? If your goal is to help others and dispense hard-earned information back to the community, stake a claim on your very own Lockergnome blog today! You can write about anything - no matter the topic. Sign-up to start blogging!

Author Avatar
Administration - Jan 2, 2008

Reporting Services On A Cluster

Author Avatar
Programming - Dec 14, 2007

Victim Of Parameter Sniffing?