Reserved Keywords (Transact-SQL)

Microsoft SQL Server 2005 uses reserved keywords for defining, manipulating, and accessing databases. Reserved keywords are part of the grammar of the Transact-SQL language that is used by SQL Server to parse and understand Transact-SQL statements and batches. Although it is syntactically possible to use SQL Server reserved keywords as identifiers and object names in Transact-SQL scripts, you can do this only by using delimited identifiers.

The following table lists SQL Server reserved keywords.

ADD

EXISTS

PRIMARY

ALL

EXIT

PRINT

ALTER

EXTERNAL

PROC

AND

FETCH

PROCEDURE

ANY

FILE

PUBLIC

AS

FILLFACTOR

RAISERROR

ASC

FOR

READ

AUTHORIZATION

FOREIGN

READTEXT

BACKUP

FREETEXT

RECONFIGURE

BEGIN

FREETEXTTABLE

REFERENCES

BETWEEN

FROM

REPLICATION

BREAK

FULL

RESTORE

BROWSE

FUNCTION

RESTRICT

BULK

GOTO

RETURN

BY

GRANT

REVERT

CASCADE

GROUP

REVOKE

CASE

HAVING

RIGHT

CHECK

HOLDLOCK

ROLLBACK

CHECKPOINT

IDENTITY

ROWCOUNT

CLOSE

IDENTITY_INSERT

ROWGUIDCOL

CLUSTERED

IDENTITYCOL

RULE

COALESCE

IF

SAVE

COLLATE

IN

SCHEMA

COLUMN

INDEX

SECURITYAUDIT

COMMIT

INNER

SELECT

COMPUTE

INSERT

SESSION_USER

CONSTRAINT

INTERSECT

SET

CONTAINS

INTO

SETUSER

CONTAINSTABLE

IS

SHUTDOWN

CONTINUE

JOIN

SOME

CONVERT

KEY

STATISTICS

CREATE

KILL

SYSTEM_USER

CROSS

LEFT

TABLE

CURRENT

LIKE

TABLESAMPLE

CURRENT_DATE

LINENO

TEXTSIZE

CURRENT_TIME

LOAD

THEN

CURRENT_TIMESTAMP

NATIONAL

TO

CURRENT_USER

NOCHECK

TOP

CURSOR

NONCLUSTERED

TRAN

DATABASE

NOT

TRANSACTION

DBCC

NULL

TRIGGER

DEALLOCATE

NULLIF

TRUNCATE

DECLARE

OF

TSEQUAL

DEFAULT

OFF

UNION

DELETE

OFFSETS

UNIQUE

DENY

ON

UNPIVOT

DESC

OPEN

UPDATE

DISK

OPENDATASOURCE

UPDATETEXT

DISTINCT

OPENQUERY

USE

DISTRIBUTED

OPENROWSET

USER

DOUBLE

OPENXML

VALUES

DROP

OPTION

VARYING

DUMP

OR

VIEW

ELSE

ORDER

WAITFOR

END

OUTER

WHEN

ERRLVL

OVER

WHERE

ESCAPE

PERCENT

WHILE

EXCEPT

PIVOT

WITH

EXEC

PLAN

WRITETEXT

EXECUTE

PRECISION

Additionally, the SQL-2003 standard defines a list of reserved keywords. Avoid using SQL-2003 reserved keywords for object names and identifiers. The ODBC reserved keyword list, shown in the following table, is the same as the SQL-2003 reserved keyword list.

Note:

The SQL-2003 reserved keywords list sometimes can be more restrictive than SQL Server and at other times less restrictive. For example, the SQL-2003 reserved keywords list contains INT. SQL Server does not have to distinguish this as a reserved keyword.

Transact-SQL reserved keywords can be used as identifiers or names of databases or database objects, such as tables, columns, views, and so on. Use either quoted identifiers or delimited identifiers. Using reserved keywords as the names of variables and stored procedure parameters is not restricted. For more information, see Using Identifiers As Object Names.

The following words are reserved for use in ODBC function calls. These words do not constrain the minimum SQL grammar; however, to ensure compatibility with drivers that support the core SQL grammar, applications should avoid using these keywords.