TechNet
Export (0) Print
Expand All

Reserved Keywords (Transact-SQL)

 

THIS TOPIC APPLIES TO: yesSQL Server (starting with 2008)yesAzure SQL DatabaseyesAzure SQL Data Warehouse yesParallel Data Warehouse

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.

ADDEXTERNALPROCEDURE
ALLFETCHPUBLIC
ALTERFILERAISERROR
ANDFILLFACTORREAD
ANYFORREADTEXT
ASFOREIGNRECONFIGURE
ASCFREETEXTREFERENCES
AUTHORIZATIONFREETEXTTABLEREPLICATION
BACKUPFROMRESTORE
BEGINFULLRESTRICT
BETWEENFUNCTIONRETURN
BREAKGOTOREVERT
BROWSEGRANTREVOKE
BULKGROUPRIGHT
BYHAVINGROLLBACK
CASCADEHOLDLOCKROWCOUNT
CASEIDENTITYROWGUIDCOL
CHECKIDENTITY_INSERTRULE
CHECKPOINTIDENTITYCOLSAVE
CLOSEIFSCHEMA
CLUSTEREDINSECURITYAUDIT
COALESCEINDEXSELECT
COLLATEINNERSEMANTICKEYPHRASETABLE
COLUMNINSERTSEMANTICSIMILARITYDETAILSTABLE
COMMITINTERSECTSEMANTICSIMILARITYTABLE
COMPUTEINTOSESSION_USER
CONSTRAINTISSET
CONTAINSJOINSETUSER
CONTAINSTABLEKEYSHUTDOWN
CONTINUEKILLSOME
CONVERTLEFTSTATISTICS
CREATELIKESYSTEM_USER
CROSSLINENOTABLE
CURRENTLOADTABLESAMPLE
CURRENT_DATEMERGETEXTSIZE
CURRENT_TIMENATIONALTHEN
CURRENT_TIMESTAMPNOCHECKTO
CURRENT_USERNONCLUSTEREDTOP
CURSORNOTTRAN
DATABASENULLTRANSACTION
DBCCNULLIFTRIGGER
DEALLOCATEOFTRUNCATE
DECLAREOFFTRY_CONVERT
DEFAULTOFFSETSTSEQUAL
DELETEONUNION
DENYOPENUNIQUE
DESCOPENDATASOURCEUNPIVOT
DISKOPENQUERYUPDATE
DISTINCTOPENROWSETUPDATETEXT
DISTRIBUTEDOPENXMLUSE
DOUBLEOPTIONUSER
DROPORVALUES
DUMPORDERVARYING
ELSEOUTERVIEW
ENDOVERWAITFOR
ERRLVLPERCENTWHEN
ESCAPEPIVOTWHERE
EXCEPTPLANWHILE
EXECPRECISIONWITH
EXECUTEPRIMARYWITHIN GROUP
EXISTSPRINTWRITETEXT
EXITPROC

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.

System_CAPS_ICON_note.jpg 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.

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.

ABSOLUTEEXECOVERLAPS
ACTIONEXECUTEPAD
ADAEXISTSPARTIAL
ADDEXTERNALPASCAL
ALLEXTRACTPOSITION
ALLOCATEFALSEPRECISION
ALTERFETCHPREPARE
ANDFIRSTPRESERVE
ANYFLOATPRIMARY
AREFORPRIOR
ASFOREIGNPRIVILEGES
ASCFORTRANPROCEDURE
ASSERTIONFOUNDPUBLIC
ATFROMREAD
AUTHORIZATIONFULLREAL
AVGGETREFERENCES
BEGINGLOBALRELATIVE
BETWEENGORESTRICT
BITGOTOREVOKE
BIT_LENGTHGRANTRIGHT
BOTHGROUPROLLBACK
BYHAVINGROWS
CASCADEHOURSCHEMA
CASCADEDIDENTITYSCROLL
CASEIMMEDIATESECOND
CASTINSECTION
CATALOGINCLUDESELECT
CHARINDEXSESSION
CHAR_LENGTHINDICATORSESSION_USER
CHARACTERINITIALLYSET
CHARACTER_LENGTHINNERSIZE
CHECKINPUTSMALLINT
CLOSEINSENSITIVESOME
COALESCEINSERTSPACE
COLLATEINTSQL
COLLATIONINTEGERSQLCA
COLUMNINTERSECTSQLCODE
COMMITINTERVALSQLERROR
CONNECTINTOSQLSTATE
CONNECTIONISSQLWARNING
CONSTRAINTISOLATIONSUBSTRING
CONSTRAINTSJOINSUM
CONTINUEKEYSYSTEM_USER
CONVERTLANGUAGETABLE
CORRESPONDINGLASTTEMPORARY
COUNTLEADINGTHEN
CREATELEFTTIME
CROSSLEVELTIMESTAMP
CURRENTLIKETIMEZONE_HOUR
CURRENT_DATELOCALTIMEZONE_MINUTE
CURRENT_TIMELOWERTO
CURRENT_TIMESTAMPMATCHTRAILING
CURRENT_USERMAXTRANSACTION
CURSORMINTRANSLATE
DATEMINUTETRANSLATION
DAYMODULETRIM
DEALLOCATEMONTHTRUE
DECNAMESUNION
DECIMALNATIONALUNIQUE
DECLARENATURALUNKNOWN
DEFAULTNCHARUPDATE
DEFERRABLENEXTUPPER
DEFERREDNOUSAGE
DELETENONEUSER
DESCNOTUSING
DESCRIBENULLVALUE
DESCRIPTORNULLIFVALUES
DIAGNOSTICSNUMERICVARCHAR
DISCONNECTOCTET_LENGTHVARYING
DISTINCTOFVIEW
DOMAINONWHEN
DOUBLEONLYWHENEVER
DROPOPENWHERE
ELSEOPTIONWITH
ENDORWORK
END-EXECORDERWRITE
ESCAPEOUTERYEAR
EXCEPTOUTPUTZONE
EXCEPTION

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.

ABSOLUTEHOSTRELATIVE
ACTIONHOURRELEASE
ADMINIGNORERESULT
AFTERIMMEDIATERETURNS
AGGREGATEINDICATORROLE
ALIASINITIALIZEROLLUP
ALLOCATEINITIALLYROUTINE
AREINOUTROW
ARRAYINPUTROWS
ASENSITIVEINTSAVEPOINT
ASSERTIONINTEGERSCROLL
ASYMMETRICINTERSECTIONSCOPE
ATINTERVALSEARCH
ATOMICISOLATIONSECOND
BEFOREITERATESECTION
BINARYLANGUAGESENSITIVE
BITLARGESEQUENCE
BLOBLASTSESSION
BOOLEANLATERALSETS
BOTHLEADINGSIMILAR
BREADTHLESSSIZE
CALLLEVELSMALLINT
CALLEDLIKE_REGEXSPACE
CARDINALITYLIMITSPECIFIC
CASCADEDLNSPECIFICTYPE
CASTLOCALSQL
CATALOGLOCALTIMESQLEXCEPTION
CHARLOCALTIMESTAMPSQLSTATE
CHARACTERLOCATORSQLWARNING
CLASSMAPSTART
CLOBMATCHSTATE
COLLATIONMEMBERSTATEMENT
COLLECTMETHODSTATIC
COMPLETIONMINUTESTDDEV_POP
CONDITIONMODSTDDEV_SAMP
CONNECTMODIFIESSTRUCTURE
CONNECTIONMODIFYSUBMULTISET
CONSTRAINTSMODULESUBSTRING_REGEX
CONSTRUCTORMONTHSYMMETRIC
CORRMULTISETSYSTEM
CORRESPONDINGNAMESTEMPORARY
COVAR_POPNATURALTERMINATE
COVAR_SAMPNCHARTHAN
CUBENCLOBTIME
CUME_DISTNEWTIMESTAMP
CURRENT_CATALOGNEXTTIMEZONE_HOUR
CURRENT_DEFAULT_TRANSFORM_GROUPNOTIMEZONE_MINUTE
CURRENT_PATHNONETRAILING
CURRENT_ROLENORMALIZETRANSLATE_REGEX
CURRENT_SCHEMANUMERICTRANSLATION
CURRENT_TRANSFORM_GROUP_FOR_TYPEOBJECTTREAT
CYCLEOCCURRENCES_REGEXTRUE
DATAOLDUESCAPE
DATEONLYUNDER
DAYOPERATIONUNKNOWN
DECORDINALITYUNNEST
DECIMALOUTUSAGE
DEFERRABLEOVERLAYUSING
DEFERREDOUTPUTVALUE
DEPTHPADVAR_POP
DEREFPARAMETERVAR_SAMP
DESCRIBEPARAMETERSVARCHAR
DESCRIPTORPARTIALVARIABLE
DESTROYPARTITIONWHENEVER
DESTRUCTORPATHWIDTH_BUCKET
DETERMINISTICPOSTFIXWITHOUT
DICTIONARYPREFIXWINDOW
DIAGNOSTICSPREORDERWITHIN
DISCONNECTPREPAREWORK
DOMAINPERCENT_RANKWRITE
DYNAMICPERCENTILE_CONTXMLAGG
EACHPERCENTILE_DISCXMLATTRIBUTES
ELEMENTPOSITION_REGEXXMLBINARY
END-EXECPRESERVEXMLCAST
EQUALSPRIORXMLCOMMENT
EVERYPRIVILEGESXMLCONCAT
EXCEPTIONRANGEXMLDOCUMENT
FALSEREADSXMLELEMENT
FILTERREALXMLEXISTS
FIRSTRECURSIVEXMLFOREST
FLOATREFXMLITERATE
FOUNDREFERENCINGXMLNAMESPACES
FREEREGR_AVGXXMLPARSE
FULLTEXTTABLEREGR_AVGYXMLPI
FUSIONREGR_COUNTXMLQUERY
GENERALREGR_INTERCEPTXMLSERIALIZE
GETREGR_R2XMLTABLE
GLOBALREGR_SLOPEXMLTEXT
GOREGR_SXXXMLVALIDATE
GROUPINGREGR_SXYYEAR
HOLDREGR_SYYZONE

SET QUOTED_IDENTIFIER (Transact-SQL)
ALTER DATABASE Compatibility Level (Transact-SQL)

Community Additions

ADD
Show:
© 2016 Microsoft