Microsoft® SQL Server™ 2000 使用保留關鍵字定義、操作和訪問數據庫。保留關鍵字是 SQL Server 使用的 Transact-SQL 語言語法的一部分,用於分析和理解 Transact-SQL 語句和批處理。盡管在 Transact-SQL 腳本中,使用 SQL Server 保留關鍵字作為標識符和對象名在語法上是可行的,但規定只能使用分隔標識符。China It Power . Com9meWH
下表列出了 SQL Server 的保留關鍵字。China It Power . Com9meWH
ADD EXCEPT PERCENT ALL EXEC PLAN ALTER EXECUTE PRECISION AND EXISTS PRIMARY ANY EXIT PRINT AS FETCH PROC ASC FILE PROCEDURE AUTHORIZATION FILLFACTOR PUBLIC BACKUP FOR RAISERROR BEGIN FOREIGN READ BETWEEN FREETEXT READTEXT BREAK FREETEXTTABLE RECONFIGURE BROWSE FROM REFERENCES BULK FULL REPLICATION BY FUNCTION RESTORE CASCADE GOTO RESTRICT CASE GRANT RETURN CHECK GROUP REVOKE CHECKPOINT HAVING RIGHT CLOSE HOLDLOCK ROLLBACK CLUSTERED IDENTITY ROWCOUNT COALESCE IDENTITY_INSERT ROWGUIDCOL COLLATE IDENTITYCOL RULE COLUMN IF SAVE COMMIT IN SCHEMA COMPUTE INDEX SELECT CONSTRAINT INNER SESSION_USER CONTAINS INSERT SET CONTAINSTABLE INTERSECT SETUSER CONTINUE INTO SHUTDOWN CONVERT IS SOME CREATE JOIN STATISTICS CROSS KEY SYSTEM_USER CURRENT KILL TABLE CURRENT_DATE LEFT TEXTSIZE CURRENT_TIME LIKE THEN CURRENT_TIMESTAMP LINENO TO CURRENT_USER LOAD TOP CURSOR NATIONAL TRAN DATABASE NOCHECK TRANSACTION DBCC NONCLUSTERED TRIGGER DEALLOCATE NOT TRUNCATE DECLARE NULL TSEQUAL DEFAULT NULLIF UNION DELETE OF UNIQUE DENY OFF UPDATE DESC OFFSETS UPDATETEXT DISK ON USE DISTINCT OPEN USER DISTRIBUTED OPENDATASOURCE VALUES DOUBLE OPENQUERY VARYING DROP OPENROWSET VIEW DUMMY OPENXML WAITFOR DUMP OPTION WHEN ELSE OR WHERE END ORDER WHILE ERRLVL OUTER WITH ESCAPE OVER WRITETEXT另外,SQL-92 標准還定義了保留關鍵字列表。不要使用 SQL-92 保留關鍵字作為對象名和標識符。ODBC 保留關鍵字列表(如下所示)與 SQL-92 保留關鍵字列表相同。China It Power . Com9meWH
說明 SQL-92 保留關鍵字列表有時可能比 SQL Server 限制更多,有時則限制更少。例如,SQL-92 保留關鍵字列表包含 INT,而 SQL Server 不需要將其區分為保留關鍵字。China It Power . Com9meWH
China It Power . Com9meWH
Transact-SQL 保留關鍵字可用作數據庫或數據庫對象(如表、列、視圖等)的標識符或名稱。使用被引用的標識符或分隔標識符。對將保留關鍵字用作變量和存儲過程參數的名稱沒有限制。China It Power . Com9meWH
保留了下列關鍵字用於 ODBC 函數調用。這些關鍵字根本不約束 SQL 語法;然而,為確保與支持核心 SQL 語法的驅動程序兼容,應用程序應避免使用這些關鍵字。China It Power . Com9meWH
下面是當前的 ODBC 保留關鍵字列表。有關更多信息,請參見《Microsoft ODBC 3.0 程序員參考》,第 2 卷,附錄 C。China It Power . Com9meWH
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以下關鍵字可能會保留在將來的 SQL Server 版本中,作為將來要實現的新特性。注意,不要使用這些關鍵字作為標識符。China It Power . Com9meWH
ABSOLUTE FOUND PRESERVE ACTION FREE 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