Microsoft® SQL Server™ uses reserved keywords for defining, manipulating, or accessing databases. Reserved keywords are part of the grammar of the Transact-SQL language 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, this can be done only by using delimited identifiers.
The SQL Server reserved keywords are:
ADD | EXIT | PRIMARY |
ALL | FETCH | |
ALTER | FILE | PRIVILEGES |
AND | FILLFACTOR | PROC |
ANY | FLOPPY | PROCEDURE |
AS | FOR | PROCESSEXIT |
ASC | FOREIGN | PUBLIC |
AUTHORIZATION | FREETEXT | RAISERROR |
AVG | FREETEXTTABLE | READ |
BACKUP | FROM | READTEXT |
BEGIN | FULL | RECONFIGURE |
BETWEEN | GOTO | REFERENCES |
BREAK | GRANT | REPEATABLE |
BROWSE | GROUP | REPLICATION |
BULK | HAVING | RESTORE |
BY | HOLDLOCK | RESTRICT |
CASCADE | IDENTITY | RETURN |
CASE | IDENTITY_INSERT | REVOKE |
CHECK | IDENTITYCOL | RIGHT |
CHECKPOINT | IF | ROLLBACK |
CLOSE | IN | ROWCOUNT |
CLUSTERED | INDEX | ROWGUIDCOL |
COALESCE | INNER | RULE |
COLUMN | INSERT | SAVE |
COMMIT | INTERSECT | SCHEMA |
COMMITTED | INTO | SELECT |
COMPUTE | IS | SERIALIZABLE |
CONFIRM | ISOLATION | SESSION_USER |
CONSTRAINT | JOIN | SET |
CONTAINS | KEY | SETUSER |
CONTAINSTABLE | KILL | SHUTDOWN |
CONTINUE | LEFT | SOME |
CONTROLROW | LEVEL | STATISTICS |
CONVERT | LIKE | SUM |
COUNT | LINENO | SYSTEM_USER |
CREATE | LOAD | TABLE |
CROSS | MAX | TAPE |
CURRENT | MIN | TEMP |
CURRENT_DATE | MIRROREXIT | TEMPORARY |
CURRENT_TIME | NATIONAL | TEXTSIZE |
CURRENT_TIMESTAMP | NOCHECK | THEN |
CURRENT_USER | NONCLUSTERED | TO |
CURSOR | NOT | TOP |
DATABASE | NULL | TRAN |
DBCC | NULLIF | TRANSACTION |
DEALLOCATE | OF | TRIGGER |
DECLARE | OFF | TRUNCATE |
DEFAULT | OFFSETS | TSEQUAL |
DELETE | ON | UNCOMMITTED |
DENY | ONCE | UNION |
DESC | ONLY | UNIQUE |
DISK | OPEN | UPDATE |
DISTINCT | OPENDATASOURCE | UPDATETEXT |
DISTRIBUTED | OPENQUERY | USE |
DOUBLE | OPENROWSET | USER |
DROP | OPTION | VALUES |
DUMMY | OR | VARYING |
DUMP | ORDER | VIEW |
ELSE | OUTER | WAITFOR |
END | OVER | WHEN |
ERRLVL | PERCENT | WHERE |
ERROREXIT | PERM | WHILE |
ESCAPE | PERMANENT | WITH |
EXCEPT | PIPE | WORK |
EXEC | PLAN | WRITETEXT |
EXECUTE | PRECISION | |
EXISTS | PREPARE |
In addition, the SQL-92 standard defines a list of reserved keywords. It is recommended that you avoid using SQL-92 reserved keywords for object names and identifiers. The ODBC reserved keyword list (shown below) is the same as the SQL-92 reserved keyword list.
Note The SQL-92 reserved keywords list sometimes can be more restrictive than SQL Server and at other times less restrictive. For example, the SQL-92 reserved keywords list contains INT, which SQL Server does not need to distinguish 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. The use of reserved keywords as the names of variables and stored procedure parameters is not restricted. For more information, see Using Identifiers.
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. For more information, see Microsoft ODBC 3.0 Programmer’s Reference, Volume 2, Appendix C.
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 |
Using Reserved Keywords | SET QUOTED_IDENTIFIER |