Partilhar via


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.

ODBC Reserved Keywords

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.

This is the current list of ODBC reserved keywords.

ABSOLUTE

EXEC

OVERLAPS

ACTION

EXECUTE

PAD

ADA

EXISTS

PARTIAL

ADD

EXTERNAL

PASCAL

ALL

EXTRACT

POSITION

ALLOCATE

FALSE

PRECISION

ALTER

FETCH

PREPARE

AND

FIRST

PRESERVE

ANY

FLOAT

PRIMARY

ARE

FOR

PRIOR

AS

FOREIGN

PRIVILEGES

ASC

FORTRAN

PROCEDURE

ASSERTION

FOUND

PUBLIC

AT

FROM

READ

AUTHORIZATION

FULL

REAL

AVG

GET

REFERENCES

BEGIN

GLOBAL

RELATIVE

BETWEEN

GO

RESTRICT

BIT

GOTO

REVOKE

BIT_LENGTH

GRANT

RIGHT

BOTH

GROUP

ROLLBACK

BY

HAVING

ROWS

CASCADE

HOUR

SCHEMA

CASCADED

IDENTITY

SCROLL

CASE

IMMEDIATE

SECOND

CAST

IN

SECTION

CATALOG

INCLUDE

SELECT

CHAR

INDEX

SESSION

CHAR_LENGTH

INDICATOR

SESSION_USER

CHARACTER

INITIALLY

SET

CHARACTER_LENGTH

INNER

SIZE

CHECK

INPUT

SMALLINT

CLOSE

INSENSITIVE

SOME

COALESCE

INSERT

SPACE

COLLATE

INT

SQL

COLLATION

INTEGER

SQLCA

COLUMN

INTERSECT

SQLCODE

COMMIT

INTERVAL

SQLERROR

CONNECT

INTO

SQLSTATE

CONNECTION

IS

SQLWARNING

CONSTRAINT

ISOLATION

SUBSTRING

CONSTRAINTS

JOIN

SUM

CONTINUE

KEY

SYSTEM_USER

CONVERT

LANGUAGE

TABLE

CORRESPONDING

LAST

TEMPORARY

COUNT

LEADING

THEN

CREATE

LEFT

TIME

CROSS

LEVEL

TIMESTAMP

CURRENT

LIKE

TIMEZONE_HOUR

CURRENT_DATE

LOCAL

TIMEZONE_MINUTE

CURRENT_TIME

LOWER

TO

CURRENT_TIMESTAMP

MATCH

TRAILING

CURRENT_USER

MAX

TRANSACTION

CURSOR

MIN

TRANSLATE

DATE

MINUTE

TRANSLATION

DAY

MODULE

TRIM

DEALLOCATE

MONTH

TRUE

DEC

NAMES

UNION

DECIMAL

NATIONAL

UNIQUE

DECLARE

NATURAL

UNKNOWN

DEFAULT

NCHAR

UPDATE

DEFERRABLE

NEXT

UPPER

DEFERRED

NO

USAGE

DELETE

NONE

USER

DESC

NOT

USING

DESCRIBE

NULL

VALUE

DESCRIPTOR

NULLIF

VALUES

DIAGNOSTICS

NUMERIC

VARCHAR

DISCONNECT

OCTET_LENGTH

VARYING

DISTINCT

OF

VIEW

DOMAIN

ON

WHEN

DOUBLE

ONLY

WHENEVER

DROP

OPEN

WHERE

ELSE

OPTION

WITH

END

OR

WORK

END-EXEC

ORDER

WRITE

ESCAPE

OUTER

YEAR

EXCEPT

OUTPUT

ZONE

EXCEPTION

 

 

Future Keywords

The following keywords could be reserved in future releases of SQL Server as new features are implemented. Consider avoiding the use of these words as identifiers.

ABSOLUTE

FREE

PRESERVE

ACTION

FULLTEXTTABLE

PRIOR

ADMIN

GENERAL

PRIVILEGES

AFTER

GET

READS

AGGREGATE

GLOBAL

REAL

ALIAS

GO

RECURSIVE

ALLOCATE

GROUPING

REF

ARE

HOST

REFERENCING

ARRAY

HOUR

RELATIVE

ASSERTION

IGNORE

RESULT

AT

IMMEDIATE

RETURNS

BEFORE

INDICATOR

ROLE

BINARY

INITIALIZE

ROLLUP

BIT

INITIALLY

ROUTINE

BLOB

INOUT

ROW

BOOLEAN

INPUT

ROWS

BOTH

INT

SAVEPOINT

BREADTH

INTEGER

SCROLL

CALL

INTERVAL

SCOPE

CASCADED

ISOLATION

SEARCH

CAST

ITERATE

SECOND

CATALOG

LANGUAGE

SECTION

CHAR

LARGE

SEQUENCE

CHARACTER

LAST

SESSION

CLASS

LATERAL

SETS

CLOB

LEADING

SIZE

COLLATION

LESS

SMALLINT

COMPLETION

LEVEL

SPACE

CONNECT

LIMIT

SPECIFIC

CONNECTION

LOCAL

SPECIFICTYPE

CONSTRAINTS

LOCALTIME

SQL

CONSTRUCTOR

LOCALTIMESTAMP

SQLEXCEPTION

CORRESPONDING

LOCATOR

SQLSTATE

CUBE

MAP

SQLWARNING

CURRENT_PATH

MATCH

START

CURRENT_ROLE

MINUTE

STATE

CYCLE

MODIFIES

STATEMENT

DATA

MODIFY

STATIC

DATE

MODULE

STRUCTURE

DAY

MONTH

TEMPORARY

DEC

NAMES

TERMINATE

DECIMAL

NATURAL

THAN

DEFERRABLE

NCHAR

TIME

DEFERRED

NCLOB

TIMESTAMP

DEPTH

NEW

TIMEZONE_HOUR

DEREF

NEXT

TIMEZONE_MINUTE

DESCRIBE

NO

TRAILING

DESCRIPTOR

NONE

TRANSLATION

DESTROY

NUMERIC

TREAT

DESTRUCTOR

OBJECT

TRUE

DETERMINISTIC

OLD

UNDER

DICTIONARY

ONLY

UNKNOWN

DIAGNOSTICS

OPERATION

UNNEST

DISCONNECT

ORDINALITY

USAGE

DOMAIN

OUT

USING

DYNAMIC

OUTPUT

VALUE

EACH

PAD

VARCHAR

END-EXEC

PARAMETER

VARIABLE

EQUALS

PARAMETERS

WHENEVER

EVERY

PARTIAL

WITHOUT

EXCEPTION

PATH

WORK

FALSE

POSTFIX

WRITE

FIRST

PREFIX

YEAR

FLOAT

PREORDER

ZONE

FOUND

PREPARE

See Also

Reference

SET QUOTED_IDENTIFIER (Transact-SQL)

Other Resources

Transact-SQL Reserved Keywords

Help and Information

Getting SQL Server 2005 Assistance

Change History

Release History

17 July 2006

New content:
  • Added EXTERNAL, PIVOT, REVERT, TABLESAMPLE, SECURITYAUDIT, and UNPIVOT to the list of reserved words.