Reserved Keywords (Transact-SQL)

Microsoft SQL Server 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

PRECISION

ALL

EXIT

PRIMARY

ALTER

EXTERNAL

PRINT

AND

FETCH

PROC

ANY

FILE

PROCEDURE

AS

FILLFACTOR

PUBLIC

ASC

FOR

RAISERROR

AUTHORIZATION

FOREIGN

READ

BACKUP

FREETEXT

READTEXT

BEGIN

FREETEXTTABLE

RECONFIGURE

BETWEEN

FROM

REFERENCES

BREAK

FULL

REPLICATION

BROWSE

FUNCTION

RESTORE

BULK

GOTO

RESTRICT

BY

GRANT

RETURN

CASCADE

GROUP

REVERT

CASE

HAVING

REVOKE

CHECK

HOLDLOCK

RIGHT

CHECKPOINT

IDENTITY

ROLLBACK

CLOSE

IDENTITY_INSERT

ROWCOUNT

CLUSTERED

IDENTITYCOL

ROWGUIDCOL

COALESCE

IF

RULE

COLLATE

IN

SAVE

COLUMN

INDEX

SCHEMA

COMMIT

INNER

SECURITYAUDIT

COMPUTE

INSERT

SELECT

CONSTRAINT

INTERSECT

SESSION_USER

CONTAINS

INTO

SET

CONTAINSTABLE

IS

SETUSER

CONTINUE

JOIN

SHUTDOWN

CONVERT

KEY

SOME

CREATE

KILL

STATISTICS

CROSS

LEFT

SYSTEM_USER

CURRENT

LIKE

TABLE

CURRENT_DATE

LINENO

TABLESAMPLE

CURRENT_TIME

LOAD

TEXTSIZE

CURRENT_TIMESTAMP

MERGE

THEN

CURRENT_USER

NATIONAL

TO

CURSOR

NOCHECK

TOP

DATABASE

NONCLUSTERED

TRAN

DBCC

NOT

TRANSACTION

DEALLOCATE

NULL

TRIGGER

DECLARE

NULLIF

TRUNCATE

DEFAULT

OF

TSEQUAL

DELETE

OFF

UNION

DENY

OFFSETS

UNIQUE

DESC

ON

UNPIVOT

DISK

OPEN

UPDATE

DISTINCT

OPENDATASOURCE

UPDATETEXT

DISTRIBUTED

OPENQUERY

USE

DOUBLE

OPENROWSET

USER

DROP

OPENXML

VALUES

DUMP

OPTION

VARYING

ELSE

OR

VIEW

END

ORDER

WAITFOR

ERRLVL

OUTER

WHEN

ESCAPE

OVER

WHERE

EXCEPT

PERCENT

WHILE

EXEC

PIVOT

WITH

EXECUTE

PLAN

WRITETEXT

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

Note

The ISO standards reserved keywords list sometimes can be more restrictive than SQL Server and at other times less restrictive. For example, the ISO 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.