Database Reference
In-Depth Information
Server tools or in a T-SQL query or script. Keywords include, but are not
limited to, the following:
SELECT
INSERT
UPDATE
DELETE
DISK
BEGIN
END
There is really no good way to know all the keywords, although there
are some references on the Internet, so your best bet is to use the compiler
and a little common sense. If you have been around SQL Server for any
length of time, you will recognize many keywords. Just remember that if
it's a command that can be used to do something in SQL Server, then it's
probably a keyword. Additionally, you can find a complete list of in
Appendix C, “SQL Server 2008 Reserved Words.”
What's the big deal? Why can't you use keywords for object names?
First of all, it can confuse other people who are trying to read a script that
was written against the database. Second, and more importantly, it confuses
the T-SQL compiler. When SQL Server encounters a script like the one
that follows, it can't make heads or tails of the syntax and throws an error.
SELECT where, and, name, date
FROM INSERT
WHERE and = 1
AND where = 'Omaha'
This is an extreme example, but you can see how SQL Server would
have no idea you have a table named INSERT with columns named
“where,” “and,” “name,” and “date.” You would receive a syntax error when
compiling this code, and you would need to surround all the keywords with
square brackets, as follows. This fixes the syntax problems but doesn't
make it any easier for a person to read.
SELECT [where], [and], name, date
FROM [INSERT]
WHERE [and] = 1
AND [where] = 'Omaha'
Search WWH ::




Custom Search