Skip to content

Instantly share code, notes, and snippets.

@daiplusplus
Last active October 21, 2022 13:39
Show Gist options
  • Save daiplusplus/94017da590a5a666d648401ab00161ef to your computer and use it in GitHub Desktop.
Save daiplusplus/94017da590a5a666d648401ab00161ef to your computer and use it in GitHub Desktop.
Useful SQL Server objects and views
CREATE VIEW dbadmin.Collations2 AS
-- https://learn.microsoft.com/en-us/sql/t-sql/statements/windows-collation-name-transact-sql?view=sql-server-ver16
WITH withSubstrings AS (
SELECT
c."name" AS "Name",
c."description" AS "Description",
CASE
WHEN "name" NOT LIKE 'SQL[_]%' THEN
CASE
WHEN "name" LIKE '%[_]90[_]%' THEN CONVERT(smallint, 90)
WHEN "name" LIKE '%[_]100[_]%' THEN CONVERT(smallint,100)
WHEN "name" LIKE '%[_]110[_]%' THEN CONVERT(smallint,110)
WHEN "name" LIKE '%[_]120[_]%' THEN CONVERT(smallint,120)
WHEN "name" LIKE '%[_]140[_]%' THEN CONVERT(smallint,140) ELSE CONVERT(smallint,80) /* "It is a version 80 collation (implied by no version number in the name)" */
END
END AS "Version",
CASE
WHEN "name" LIKE '%[_]CS' OR "name" LIKE '%[_]CS[_]%' THEN CONVERT(bit,1)
WHEN "name" LIKE '%[_]CI' OR "name" LIKE '%[_]CI[_]%' THEN CONVERT(bit,0)
END AS "CaseSensitive",
CASE
WHEN "name" LIKE '%[_]AS' OR "name" LIKE '%[_]AS[_]%' THEN CONVERT(bit,1)
WHEN "name" LIKE '%[_]AI' OR "name" LIKE '%[_]AI[_]%' THEN CONVERT(bit,0)
END AS "AccentSensitive",
CASE WHEN "name" LIKE '%[_]KS' OR "name" LIKE '%[_]KS[_]%' THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS "KanatypeSensitive",
CASE WHEN "name" LIKE '%[_]WS' OR "name" LIKE '%[_]WS[_]%' THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS "WidthSensitive",
CASE WHEN "name" LIKE '%[_]VSS' OR "name" LIKE '%[_]VSS[_]%' THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS "VariationSelectorSensitive",
CASE WHEN "name" LIKE 'SQL[_]%' THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS "LegacySqlCollation", /* https://learn.microsoft.com/en-us/sql/t-sql/statements/sql-server-collation-name-transact-sql?view=sql-server-ver16 */
CASE WHEN "name" LIKE '%[_]UTF8' THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS "UTF8",
CASE WHEN "name" LIKE '%[_]BIN' THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS "LegacyBinary",
CASE WHEN "name" LIKE '%[_]BIN2' THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS "BinaryCodePoint"
FROM
sys.fn_helpcollations() AS c
),
withSubstrings2 AS (
SELECT
"Name",
"Description",
"Version",
CaseSensitive,
AccentSensitive,
KanatypeSensitive,
WidthSensitive,
VariationSelectorSensitive,
LegacySqlCollation,
"UTF8",
LegacyBinary,
BinaryCodePoint,
CASE WHEN ( /*"Version" < 100 OR*/ "LegacySqlCollation" = 1 OR "LegacyBinary" = 1 ) THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS "IsLegacy",
CASE "Version"
WHEN 80 THEN
CASE
WHEN "LegacyBinary" = 1 THEN SUBSTRING( "name", 1, PATINDEX( '%[_]BIN' , "name" ) - 1 )
WHEN "BinaryCodePoint" = 1 THEN SUBSTRING( "name", 1, PATINDEX( '%[_]BIN2', "name" ) - 1 ) ELSE SUBSTRING( "name", 1, CHARINDEX( '_C' , "name", 1 ) - 1 )
END
WHEN 90 THEN SUBSTRING( "name", 1, CHARINDEX( '_90_' , "name", 1 ) - 1 )
WHEN 100 THEN SUBSTRING( "name", 1, CHARINDEX( '_100_', "name", 1 ) - 1 )
WHEN 110 THEN SUBSTRING( "name", 1, CHARINDEX( '_110_', "name", 1 ) - 1 )
WHEN 120 THEN SUBSTRING( "name", 1, CHARINDEX( '_120_', "name", 1 ) - 1 )
WHEN 140 THEN SUBSTRING( "name", 1, CHARINDEX( '_140_', "name", 1 ) - 1 )
END AS WindowsCollationName
FROM
withSubstrings
)
SELECT
"Name",
"Description",
"Version",
CaseSensitive,
AccentSensitive,
KanatypeSensitive,
WidthSensitive,
VariationSelectorSensitive,
LegacySqlCollation,
"UTF8",
LegacyBinary,
BinaryCodePoint,
IsLegacy,
WindowsCollationName
FROM
withSubstrings2;
CREATE VIEW [dbadmin].[ForeignKeyDefinitions] AS
WITH columnsConcat AS (
SELECT
fkc.constraint_object_id, /* <-- i.e. the `FK_From_To` object */
STRING_AGG( dbadmin.QuoteNameIfNecessary( c_parent.[name] ), /* separator: */ ', ' ) AS dependent_cols, /* i.e. dependent */
STRING_AGG( dbadmin.QuoteNameIfNecessary( c_referenced.[name] ), /* separator: */ ', ' ) AS principal_cols, /* i.e. principal */
STRING_AGG( CONCAT( N'po.', dbadmin.QuoteNameIfNecessary( c_parent.[name] ), N' = ro.', dbadmin.QuoteNameIfNecessary( c_referenced.[name] ) ), /* separator: */ ' AND ' ) AS cols_join,
STRING_AGG( CONCAT( N'po.', dbadmin.QuoteNameIfNecessary( c_parent.[name] ), ' IS NULL' ), /* separator: */ ' AND ' ) AS dependent_cols_is_null,
STRING_AGG( CONCAT( N'ro.', dbadmin.QuoteNameIfNecessary( c_referenced.[name] ), ' IS NOT NULL' ), /* separator: */ ' AND ' ) AS principal_cols_is_not_null
FROM
sys.foreign_key_columns AS fkc
INNER JOIN sys.columns AS c_parent ON
fkc.parent_object_id = c_parent."object_id"
AND
fkc.parent_column_id = c_parent.column_id
INNER JOIN sys.columns AS c_referenced ON
fkc.referenced_object_id = c_referenced."object_id"
AND
fkc.referenced_column_id = c_referenced.column_id
GROUP BY
fkc.constraint_object_id
)
SELECT
c.constraint_object_id,
fk.[name] AS foreign_key_name,
dbadmin.FullName( fk.parent_object_id ) AS dependent_table,
dbadmin.FullName( fk.referenced_object_id ) AS principal_table,
c.dependent_cols,
c.principal_cols,
FORMATMESSAGE(
N'SELECT
po.*
FROM
%s AS po
LEFT OUTER JOIN %s AS ro ON
%s
WHERE
%s
AND
%s;
',
dbadmin.FullName( fk.parent_object_id ),
dbadmin.FullName( fk.referenced_object_id ),
c.cols_join,
c.dependent_cols_is_null,
c.principal_cols_is_not_null
) AS select_invalid_rows,
FORMATMESSAGE(
N'ALTER TABLE %s DROP CONSTRAINT %s;',
dbadmin.FullName( fk.parent_object_id ),
dbadmin.FullName( fk."object_id" )
) AS drop_foreign_key,
FORMATMESSAGE(
N'ALTER TABLE %s ADD CONSTRAINT %s FOREIGN KEY ( %s ) REFERENCES %s ( %s ) ON DELETE %s ON UPDATE %s;',
dbadmin.FullName( fk.parent_object_id ),
dbadmin.FullName( fk."object_id" ),
c.dependent_cols,
dbadmin.FullName( fk.referenced_object_id ),
c.principal_cols,
fk.delete_referential_action_desc,
fk.update_referential_action_desc
) AS create_foreign_key,
FORMATMESSAGE(
N'ALTER TABLE %s NOCHECK CONSTRAINT %s;',
dbadmin.FullName( fk.parent_object_id ),
dbadmin.FullName( fk."object_id" )
) AS disable_foreign_key
FROM
columnsConcat AS c
INNER JOIN sys.foreign_keys AS fk ON
c.constraint_object_id = fk."object_id"
INNER JOIN sys.tables AS table_parent ON
fk.parent_object_id = table_parent."object_id"
INNER JOIN sys.tables AS table_referenced ON
fk.referenced_object_id = table_referenced."object_id"
;
CREATE FUNCTION [dbadmin].[QuoteNameIfNecessary]( @name sysname )
RETURNS sysname /* sysname == nvarchar(128) */
WITH SCHEMABINDING, RETURNS NULL ON NULL INPUT, INLINE = ON
AS
BEGIN
/*
Changelog:
* Version 1.
* Version 2:
* Hopefully improving performance by:
* Doing LIKE check before doing ReservedWords lookup.
* Adding `WITH SCHEMABINDING`.
* Adding `WITH RETURNS NULL ON NULL INPUT`. (This also means the `IF @name IS NULL` check is handled by SQL Server for us).
* Using nvarchar literals N'' as `sysname` is also nvarchar.
* Adding `WITH (NOLOCK)` for ReservedWords table.
* Correctness fixes
* Implementing rules for first character vs. subsequent characters (via https://sqlquantumleap.com/reference/completely-complete-list-of-rules-for-t-sql-identifiers/ ).
* Alowing _ in first char.
* Allowing #, $, @, _ in subsequent chars.
* Version 2.1:
* Converted to `INLINE = ON` by using a single `RETURN` point.
* Ideas for version 3:
* Performance: Convert to an inline table-valued function, this is doable by converting the `IF` checks to CASE expressions.
* This will really boost performance btw: https://www.mssqltips.com/sqlservertip/5864/four-ways-to-improve-scalar-function-performance-in-sql-server/
* Performance: Move `ReservedWords` table to a READONLY filegroup ( https://blog.sqlauthority.com/2015/03/17/sql-server-marking-filegroup-as-readonly-with-sql-server/ )
* Correctness:
* Allow chars from Unicode `Id_Start` and `Id_Continue` categories, as per sqlquantumleap.com article.
*/
/* https://stackoverflow.com/questions/12246156/repeating-characters-in-t-sql-like-condition */
/* https://sqlquantumleap.com/reference/completely-complete-list-of-rules-for-t-sql-identifiers/ */
DECLARE @result sysname;
IF @name LIKE N'[A-Z_a-z]%' COLLATE Latin1_General_BIN -- First character is valid for unquoted identifier (see sqlquantumleap.com article).
BEGIN
IF @name LIKE N'%[^#$0-9@A-Z_a-z]%' COLLATE Latin1_General_BIN -- @name contains a non-quoted-unsafe character (observe how it uses `LIKE [^]` instead of `LIKE []`).
BEGIN
SET @result = QUOTENAME( @name, N'"' );
END
ELSE -- @name does not contain any characters not in `[#$0-9@A-Z_a-z]` (which are all permitted inside an identifier, after the first char)
BEGIN
DECLARE @len int = LEN( @name ); /* dbadmin.ReservedWords contains tokens in this length range. */
IF ( @len >= 2 AND @len <= 23 ) OR ( @len IN ( 30, 31, 32, 34 ) )
BEGIN
IF EXISTS( SELECT 1 FROM dbadmin.ReservedWords WITH (NOLOCK) WHERE Word = @name ) /* TODO: Force case-insensitive collation for comparison, and ensure the base table and index uses it too. */
BEGIN
SET @result = QUOTENAME( @name, N'"' );
END;
ELSE
BEGIN
SET @result = @name;
END
END;
ELSE
BEGIN
SET @result = @name;
END
END;
END;
ELSE
BEGIN
-- @name's first-character is not in the set of valid first-characters.
SET @result = QUOTENAME( @name, N'"' );
END;
RETURN @result;
END
CREATE TABLE dbadmin.ReservedWords (
Word sysname NOT NULL /* sysname == nvarchar(128) */
CONSTRAINT PK_ReservedWords PRIMARY KEY ( Word )
);
GO
INSERT INTO dbadmin.ReservedWords ( Word )
VALUES
( N'$action' ),
( N'$PARTITION' ),
( N'$rowguid' ),
( N'@@CONNECTIONS' ),
( N'@@CPU_BUSY' ),
( N'@@CURSOR_ROWS' ),
( N'@@DATEFIRST' ),
( N'@@DBTS' ),
( N'@@ERROR' ),
( N'@@FETCH_STATUS' ),
( N'@@IDENTITY' ),
( N'@@IDLE' ),
( N'@@IO_BUSY' ),
( N'@@LANGID' ),
( N'@@LANGUAGE' ),
( N'@@LOCK_TIMEOUT' ),
( N'@@MAX_CONNECTIONS' ),
( N'@@MAX_PRECISION' ),
( N'@@NESTLEVEL' ),
( N'@@OPTIONS' ),
( N'@@PACK_RECEIVED' ),
( N'@@PACK_SENT' ),
( N'@@PACKET_ERRORS' ),
( N'@@PROCID' ),
( N'@@REMSERVER' ),
( N'@@ROWCOUNT' ),
( N'@@SERVERNAME' ),
( N'@@SERVICENAME' ),
( N'@@SPID' ),
( N'@@TEXTSIZE' ),
( N'@@TIMETICKS' ),
( N'@@TOTAL_ERRORS' ),
( N'@@TOTAL_READ' ),
( N'@@TOTAL_WRITE' ),
( N'@@TRANCOUNT' ),
( N'@@VERSION' ),
( N'ABS' ),
( N'ABSOLUTE' ),
( N'ACOS' ),
( N'ACTION' ),
( N'ADA' ),
( N'ADD' ),
( N'ADMIN' ),
( N'AFTER' ),
( N'AGGREGATE' ),
( N'ALIAS' ),
( N'ALL' ),
( N'ALLOCATE' ),
( N'ALTER' ),
( N'AND' ),
( N'ANY' ),
( N'APP_NAME' ),
( N'APPLOCK_MODE' ),
( N'APPLOCK_TEST' ),
( N'APPLY' ),
( N'APPROX_COUNT_DISTINCT' ),
( N'ARE' ),
( N'ARRAY' ),
( N'AS' ),
( N'ASC' ),
( N'ASCII' ),
( N'ASENSITIVE' ),
( N'ASIN' ),
( N'ASSEMBLYPROPERTY' ),
( N'ASSERTION' ),
( N'ASYMKEY_ID' ),
( N'ASYMKEYPROPERTY' ),
( N'ASYMMETRIC' ),
( N'AT' ),
( N'ATAN' ),
( N'ATN2' ),
( N'ATOMIC' ),
( N'AUTHORIZATION' ),
( N'AVG' ),
( N'BACKUP' ),
( N'BEFORE' ),
( N'BEGIN' ),
( N'BETWEEN' ),
( N'bigint' ),
( N'BINARY' ),
( N'BINARY_CHECKSUM' ),
( N'BIT' ),
( N'BIT_LENGTH' ),
( N'BLOB' ),
( N'BOOLEAN' ),
( N'BOTH' ),
( N'BREADTH' ),
( N'BREAK' ),
( N'BROWSE' ),
( N'BULK' ),
( N'BY' ),
( N'CALL' ),
( N'CALLED' ),
( N'CARDINALITY' ),
( N'CASCADE' ),
( N'CASCADED' ),
( N'CASE' ),
( N'CAST' ),
( N'CATALOG' ),
( N'CATCH' ),
( N'CEILING' ),
( N'CERTENCODED' ),
( N'CERTPRIVATEKEY' ),
( N'CHAR' ),
( N'CHAR_LENGTH' ),
( N'CHARACTER' ),
( N'CHARACTER_LENGTH' ),
( N'CHARINDEX' ),
( N'CHECK' ),
( N'CHECKALLOC' ),
( N'CHECKCATALOG' ),
( N'CHECKCONSTRAINTS' ),
( N'CHECKDB' ),
( N'CHECKFILEGROUP' ),
( N'CHECKIDENT' ),
( N'CHECKPOINT' ),
( N'CHECKSUM' ),
( N'CHECKSUM_AGG' ),
( N'CHECKTABLE' ),
( N'CHOOSE' ),
( N'CLASS' ),
( N'CLEANTABLE' ),
( N'CLOB' ),
( N'CLONEDATABASE' ),
( N'CLOSE' ),
( N'CLUSTERED' ),
( N'COALESCE' ),
( N'COL_LENGTH' ),
( N'COL_NAME' ),
( N'COLLATE' ),
( N'COLLATION' ),
( N'COLLATIONPROPERTY' ),
( N'COLLECT' ),
( N'COLUMN' ),
( N'COLUMNPROPERTY' ),
( N'COLUMNS_UPDATED' ),
( N'COMMIT' ),
( N'COMPLETION' ),
( N'COMPRESS' ),
( N'COMPUTE' ),
( N'CONCAT' ),
( N'CONCAT_WS' ),
( N'CONDITION' ),
( N'CONNECT' ),
( N'CONNECTION' ),
( N'CONNECTIONPROPERTY' ),
( N'CONSTRAINT' ),
( N'CONSTRAINTS' ),
( N'CONSTRUCTOR' ),
( N'CONTAINS' ),
( N'CONTAINSTABLE' ),
( N'CONTEXT_INFO' ),
( N'CONTINUE' ),
( N'CONVERT' ),
( N'CORR' ),
( N'CORRESPONDING' ),
( N'COS' ),
( N'COT' ),
( N'COUNT' ),
( N'COUNT_BIG' ),
( N'COVAR_POP' ),
( N'COVAR_SAMP' ),
( N'CREATE' ),
( N'CROSS' ),
( N'CUBE' ),
( N'CUME_DIST' ),
( N'CURRENT' ),
( N'CURRENT_CATALOG' ),
( N'CURRENT_DATE' ),
( N'CURRENT_DEFAULT_TRANSFORM_GROUP' ),
( N'CURRENT_PATH' ),
( N'CURRENT_REQUEST_ID' ),
( N'CURRENT_ROLE' ),
( N'CURRENT_SCHEMA' ),
( N'CURRENT_TIME' ),
( N'CURRENT_TIMESTAMP' ),
( N'CURRENT_TRANSACTION_ID' ),
( N'CURRENT_TRANSFORM_GROUP_FOR_TYPE' ),
( N'CURRENT_USER' ),
( N'CURSOR' ),
( N'CURSOR_STATUS' ),
( N'CYCLE' ),
( N'DATA' ),
( N'DATABASE' ),
( N'DATABASE_PRINCIPAL_ID' ),
( N'DATABASEPROPERTYEX' ),
( N'DATALENGTH' ),
( N'DATE' ),
( N'DATEADD' ),
( N'DATEDIFF' ),
( N'DATEDIFF_BIG' ),
( N'DATEFROMPARTS' ),
( N'DATENAME' ),
( N'DATEPART' ),
( N'datetime' ),
( N'datetime2' ),
( N'DATETIME2FROMPARTS' ),
( N'DATETIMEFROMPARTS' ),
( N'datetimeoffset' ),
( N'DATETIMEOFFSETFROMPARTS' ),
( N'DAY' ),
( N'DB_ID' ),
( N'DB_NAME' ),
( N'DBCC' ),
( N'DBREINDEX' ),
( N'DEALLOCATE' ),
( N'DEC' ),
( N'DECIMAL' ),
( N'DECLARE' ),
( N'DECOMPRESS' ),
( N'DECRYPTBYASYMKEY' ),
( N'DECRYPTBYCERT' ),
( N'DECRYPTBYKEY' ),
( N'DECRYPTBYKEYAUTOASYMKEY' ),
( N'DecryptByKeyAutoCert' ),
( N'DECRYPTBYPASSPHRASE' ),
( N'DEFAULT' ),
( N'DEFERRABLE' ),
( N'DEFERRED' ),
( N'DEGREES' ),
( N'DELETE' ),
( N'DENSE_RANK' ),
( N'DENY' ),
( N'DEPTH' ),
( N'DEREF' ),
( N'DESC' ),
( N'DESCRIBE' ),
( N'Description' ),
( N'DESCRIPTOR' ),
( N'DESTROY' ),
( N'DESTRUCTOR' ),
( N'DETERMINISTIC' ),
( N'DIAGNOSTICS' ),
( N'DICTIONARY' ),
( N'DIFFERENCE' ),
( N'DISCONNECT' ),
( N'DISK' ),
( N'DISTINCT' ),
( N'DISTRIBUTED' ),
( N'DOMAIN' ),
( N'DOUBLE' ),
( N'DROP' ),
( N'DROPCLEANBUFFERS' ),
( N'DUMP' ),
( N'DYNAMIC' ),
( N'EACH' ),
( N'ELEMENT' ),
( N'ELSE' ),
( N'ENCRYPTBYASYMKEY' ),
( N'ENCRYPTBYCERT' ),
( N'ENCRYPTBYKEY' ),
( N'ENCRYPTBYPASSPHRASE' ),
( N'END' ),
( N'END-EXEC' ),
( N'EOMONTH' ),
( N'EQUALS' ),
( N'ERRLVL' ),
( N'ERROR_LINE' ),
( N'ERROR_MESSAGE' ),
( N'ERROR_NUMBER' ),
( N'ERROR_PROCEDURE' ),
( N'ERROR_SEVERITY' ),
( N'ERROR_STATE' ),
( N'ESCAPE' ),
( N'EVENTDATA' ),
( N'EVERY' ),
( N'EXCEPT' ),
( N'EXCEPTION' ),
( N'EXEC' ),
( N'EXECUTE' ),
( N'EXISTS' ),
( N'EXIT' ),
( N'EXP' ),
( N'EXTERNAL' ),
( N'EXTRACT' ),
( N'FALSE' ),
( N'FETCH' ),
( N'FILE' ),
( N'FILE_ID' ),
( N'FILE_IDEX' ),
( N'FILE_NAME' ),
( N'FILEGROUP_ID' ),
( N'FILEGROUP_NAME' ),
( N'FILEGROUPPROPERTY' ),
( N'FILEPROPERTY' ),
( N'FILLFACTOR' ),
( N'FILTER' ),
( N'FIRST' ),
( N'FIRST_VALUE' ),
( N'FLOAT' ),
( N'FLOOR' ),
( N'FLUSHAUTHCACHE' ),
( N'fn_virtualfilestats' ),
( N'FOR' ),
( N'FOREIGN' ),
( N'FORMAT' ),
( N'FORMATMESSAGE' ),
( N'FORTRAN' ),
( N'FOUND' ),
( N'FREE' ),
( N'FREEPROCCACHE' ),
( N'FREESESSIONCACHE' ),
( N'FREESYSTEMCACHE' ),
( N'FREETEXT' ),
( N'FREETEXTTABLE' ),
( N'FROM' ),
( N'FULL' ),
( N'FULLTEXTCATALOGPROPERTY' ),
( N'FULLTEXTSERVICEPROPERTY' ),
( N'FULLTEXTTABLE' ),
( N'FUNCTION' ),
( N'FUSION' ),
( N'GENERAL' ),
( N'geography' ),
( N'geometry' ),
( N'GET' ),
( N'GET_FILESTREAM_TRANSACTION_CONTEXT' ),
( N'GETANSINULL' ),
( N'GETDATE' ),
( N'GETUTCDATE' ),
( N'GLOBAL' ),
( N'GO' ),
( N'GOTO' ),
( N'GRANT' ),
( N'GREATEST' ),
( N'GROUP' ),
( N'GROUPING' ),
( N'GROUPING_ID' ),
( N'GROUPINGS' ),
( N'HASHBYTES' ),
( N'HAVING' ),
( N'HELP' ),
( N'hierarchyid' ),
( N'HOLD' ),
( N'HOLDLOCK' ),
( N'HOST' ),
( N'HOST_ID' ),
( N'HOST_NAME' ),
( N'HOUR' ),
( N'IDENT_CURRENT' ),
( N'IDENT_INCR' ),
( N'IDENT_SEED' ),
( N'IDENTITY' ),
( N'IDENTITY_INSERT' ),
( N'IDENTITYCOL' ),
( N'IF' ),
( N'IGNORE' ),
( N'IIF' ),
( N'image' ),
( N'IMMEDIATE' ),
( N'IN' ),
( N'INCLUDE' ),
( N'INDEX' ),
( N'INDEX_COL' ),
( N'INDEXDEFRAG' ),
( N'INDEXKEY_PROPERTY' ),
( N'INDEXPROPERTY' ),
( N'INDICATOR' ),
( N'INITIALIZE' ),
( N'INITIALLY' ),
( N'INNER' ),
( N'INOUT' ),
( N'INPUT' ),
( N'INPUTBUFFER' ),
( N'INSENSITIVE' ),
( N'INSERT' ),
( N'INT' ),
( N'INTEGER' ),
( N'INTERSECT' ),
( N'INTERSECTION' ),
( N'INTERVAL' ),
( N'INTO' ),
( N'IS' ),
( N'IS_OBJECTSIGNED' ),
( N'ISDATE' ),
( N'ISJSON' ),
( N'ISNULL' ),
( N'ISNUMERIC' ),
( N'ISOLATION' ),
( N'ITERATE' ),
( N'JOIN' ),
( N'JSON_MODIFY' ),
( N'JSON_QUERY' ),
( N'JSON_VALUE' ),
( N'KEY' ),
( N'KEY_GUID' ),
( N'KEY_ID' ),
( N'KEY_NAME' ),
( N'KILL' ),
( N'LABEL' ),
( N'LAG' ),
( N'LANGUAGE' ),
( N'LARGE' ),
( N'LAST' ),
( N'LAST_VALUE' ),
( N'LATERAL' ),
( N'LEAD' ),
( N'LEADING' ),
( N'LEAST' ),
( N'LEFT' ),
( N'LEN' ),
( N'LESS' ),
( N'LEVEL' ),
( N'LIKE' ),
( N'LIKE_REGEX' ),
( N'LIMIT' ),
( N'LINENO' ),
( N'LN' ),
( N'LOAD' ),
( N'LOCAL' ),
( N'LOCALTIME' ),
( N'LOCALTIMESTAMP' ),
( N'LOCATOR' ),
( N'LOG' ),
( N'LOG10' ),
( N'LOWER' ),
( N'LTRIM' ),
( N'MAP' ),
( N'MATCH' ),
( N'MAX' ),
( N'MEMBER' ),
( N'MERGE' ),
( N'METHOD' ),
( N'MIN' ),
( N'MIN_ACTIVE_ROWVERSION' ),
( N'MINUTE' ),
( N'MOD' ),
( N'MODIFIES' ),
( N'MODIFY' ),
( N'MODULE' ),
( N'money' ),
( N'MONTH' ),
( N'MULTISET' ),
( N'Name' ),
( N'NAMES' ),
( N'NATIONAL' ),
( N'NATURAL' ),
( N'NCHAR' ),
( N'NCLOB' ),
( N'NEW' ),
( N'NEWID' ),
( N'NEWSEQUENTIALID' ),
( N'NEXT' ),
( N'NO' ),
( N'NOCHECK' ),
( N'NONCLUSTERED' ),
( N'NONE' ),
( N'NORMALIZE' ),
( N'NOT' ),
( N'ntext' ),
( N'NTILE' ),
( N'NULL' ),
( N'NULLIF' ),
( N'NUMERIC' ),
( N'nvarchar' ),
( N'OBJECT' ),
( N'OBJECT_DEFINITION' ),
( N'OBJECT_ID' ),
( N'OBJECT_NAME' ),
( N'OBJECT_SCHEMA_NAME' ),
( N'OBJECTPROPERTY' ),
( N'OBJECTPROPERTYEX' ),
( N'OCCURRENCES_REGEX' ),
( N'OCTET_LENGTH' ),
( N'OF' ),
( N'OFF' ),
( N'OFFSETS' ),
( N'OLD' ),
( N'ON' ),
( N'ONLY' ),
( N'OPEN' ),
( N'OPENDATASOURCE' ),
( N'OPENJSON' ),
( N'OPENQUERY' ),
( N'OPENROWSET' ),
( N'OPENTRAN' ),
( N'OPENXML' ),
( N'OPERATION' ),
( N'OPTION' ),
( N'OR' ),
( N'ORDER' ),
( N'ORDINALITY' ),
( N'ORIGINAL_DB_NAME' ),
( N'OUT' ),
( N'OUTER' ),
( N'OUTPUT' ),
( N'OUTPUTBUFFER' ),
( N'OVER' ),
( N'OVERLAPS' ),
( N'OVERLAY' ),
( N'PAD' ),
( N'PARAMETER' ),
( N'PARAMETERS' ),
( N'PARSE' ),
( N'PARSENAME' ),
( N'PARTIAL' ),
( N'PARTITION' ),
( N'PASCAL' ),
( N'PATH' ),
( N'PATINDEX' ),
( N'PERCENT' ),
( N'PERCENT_RANK' ),
( N'PERCENTILE_CONT' ),
( N'PERCENTILE_DISC' ),
( N'PI' ),
( N'PIVOT' ),
( N'PLAN' ),
( N'POSITION' ),
( N'POSITION_REGEX' ),
( N'POSTFIX' ),
( N'POWER' ),
( N'PRECISION' ),
( N'PREDICT' ),
( N'PREFIX' ),
( N'PREORDER' ),
( N'PREPARE' ),
( N'PRESERVE' ),
( N'PRIMARY' ),
( N'PRINT' ),
( N'PRIOR' ),
( N'PRIVILEGES' ),
( N'PROC' ),
( N'PROCCACHE' ),
( N'PROCEDURE' ),
( N'PUBLIC' ),
( N'PUBLISHINGSERVERNAME' ),
( N'QUOTENAME' ),
( N'RADIANS' ),
( N'RAISERROR' ),
( N'RAND' ),
( N'RANGE' ),
( N'RANK' ),
( N'READ' ),
( N'READS' ),
( N'READTEXT' ),
( N'REAL' ),
( N'RECONFIGURE' ),
( N'RECURSIVE' ),
( N'REF' ),
( N'REFERENCES' ),
( N'REFERENCING' ),
( N'REGR_AVGX' ),
( N'REGR_AVGY' ),
( N'REGR_COUNT' ),
( N'REGR_INTERCEPT' ),
( N'REGR_R2' ),
( N'REGR_SLOPE' ),
( N'REGR_SXX' ),
( N'REGR_SXY' ),
( N'REGR_SYY' ),
( N'RELATIVE' ),
( N'RELEASE' ),
( N'REPLACE' ),
( N'REPLICATE' ),
( N'REPLICATION' ),
( N'RESTORE' ),
( N'RESTRICT' ),
( N'RESULT' ),
( N'RETURN' ),
( N'RETURNS' ),
( N'REVERSE' ),
( N'REVERT' ),
( N'REVOKE' ),
( N'RIGHT' ),
( N'ROLE' ),
( N'ROLLBACK' ),
( N'ROLLUP' ),
( N'ROUND' ),
( N'ROUTINE' ),
( N'ROW' ),
( N'ROW_NUMBER' ),
( N'ROWCOUNT' ),
( N'ROWCOUNT_BIG' ),
( N'ROWGUIDCOL' ),
( N'ROWS' ),
( N'rowversion' ),
( N'RTRIM' ),
( N'RULE' ),
( N'SAVE' ),
( N'SAVEPOINT' ),
( N'SCHEMA' ),
( N'SCHEMA_ID' ),
( N'SCHEMA_NAME' ),
( N'SCOPE' ),
( N'SCOPE_IDENTITY' ),
( N'SCROLL' ),
( N'SEARCH' ),
( N'SECOND' ),
( N'SECTION' ),
( N'SECURITYAUDIT' ),
( N'SELECT' ),
( N'SEMANTICKEYPHRASETABLE' ),
( N'SEMANTICSIMILARITYDETAILSTABLE' ),
( N'SEMANTICSIMILARITYTABLE' ),
( N'SENSITIVE' ),
( N'SEQUENCE' ),
( N'SERVERPROPERTY' ),
( N'SESSION' ),
( N'SESSION_CONTEXT' ),
( N'SESSION_ID' ),
( N'SESSION_USER' ),
( N'SET' ),
( N'SETS' ),
( N'SETUSER' ),
( N'SHOW_STATISTICS' ),
( N'SHOWCONTIG' ),
( N'SHRINKDATABASE' ),
( N'SHRINKFILE' ),
( N'SHUTDOWN' ),
( N'SIGN' ),
( N'SIGNBYASYMKEY' ),
( N'SIGNBYCERT' ),
( N'SIMILAR' ),
( N'SIN' ),
( N'SIZE' ),
( N'smalldatetime' ),
( N'SMALLDATETIMEFROMPARTS' ),
( N'SMALLINT' ),
( N'smallmoney' ),
( N'SOME' ),
( N'SOUNDEX' ),
( N'SPACE' ),
( N'SPECIFIC' ),
( N'SPECIFICTYPE' ),
( N'SQL' ),
( N'sql_variant' ),
( N'SQL_VARIANT_PROPERTY' ),
( N'SQLCA' ),
( N'SQLCODE' ),
( N'SQLERROR' ),
( N'SQLEXCEPTION' ),
( N'SQLPERF' ),
( N'SQLSTATE' ),
( N'SQLWARNING' ),
( N'SQRT' ),
( N'SQUARE' ),
( N'START' ),
( N'STATE' ),
( N'STATEMENT' ),
( N'STATIC' ),
( N'STATISTICS' ),
( N'STATS_DATE' ),
( N'STATUS' ),
( N'STDDEV_POP' ),
( N'STDDEV_SAMP' ),
( N'STDEV' ),
( N'STDEVP' ),
( N'STR' ),
( N'STRING_AGG' ),
( N'STRING_ESCAPE' ),
( N'STRING_SPLIT' ),
( N'STRUCTURE' ),
( N'STUFF' ),
( N'SUBMULTISET' ),
( N'SUBSTRING' ),
( N'SUBSTRING_REGEX' ),
( N'SUM' ),
( N'SWITCHOFFSET' ),
( N'SYMKEYPROPERTY' ),
( N'SYMMETRIC' ),
( N'SYSDATETIME' ),
( N'SYSDATETIMEOFFSET' ),
( N'SYSTEM' ),
( N'SYSTEM_USER' ),
( N'SYSUTCDATETIME' ),
( N'TABLE' ),
( N'TABLESAMPLE' ),
( N'TAN' ),
( N'TEMPORARY' ),
( N'TERMINATE' ),
( N'TERTIARY_WEIGHTS' ),
( N'text' ),
( N'TEXTPTR' ),
( N'TEXTSIZE' ),
( N'TEXTVALID' ),
( N'THAN' ),
( N'THEN' ),
( N'THROW' ),
( N'TIME' ),
( N'TIMEFROMPARTS' ),
( N'TIMESTAMP' ),
( N'TIMEZONE_HOUR' ),
( N'TIMEZONE_MINUTE' ),
( N'tinyint' ),
( N'TO' ),
( N'TODATETIMEOFFSET' ),
( N'TOP' ),
( N'TRACEOFF' ),
( N'TRACEON' ),
( N'TRACESTATUS' ),
( N'TRAILING' ),
( N'TRAN' ),
( N'TRANSACTION' ),
( N'TRANSLATE' ),
( N'TRANSLATE_REGEX' ),
( N'TRANSLATION' ),
( N'TREAT' ),
( N'TRIGGER' ),
( N'TRIGGER_NESTLEVEL' ),
( N'TRIM' ),
( N'TRUE' ),
( N'TRUNCATE' ),
( N'TRY' ),
( N'TRY_CAST' ),
( N'TRY_CONVERT' ),
( N'TRY_PARSE' ),
( N'TSEQUAL' ),
( N'Type' ),
( N'TYPE_ID' ),
( N'TYPE_NAME' ),
( N'TYPEPROPERTY' ),
( N'UESCAPE' ),
( N'UNDER' ),
( N'UNICODE' ),
( N'UNION' ),
( N'UNIQUE' ),
( N'uniqueidentifier' ),
( N'UNKNOWN' ),
( N'UNNEST' ),
( N'UNPIVOT' ),
( N'UPDATE' ),
( N'UPDATETEXT' ),
( N'UPDATEUSAGE' ),
( N'UPPER' ),
( N'USAGE' ),
( N'USE' ),
( N'USER' ),
( N'USEROPTIONS' ),
( N'USING' ),
( N'VALUE' ),
( N'VALUES' ),
( N'VAR' ),
( N'VAR_POP' ),
( N'VAR_SAMP' ),
( N'varbinary' ),
( N'VARCHAR' ),
( N'VARIABLE' ),
( N'VARP' ),
( N'VARYING' ),
( N'VERIFYSIGNEDBYASMKEY' ),
( N'VERIGYSIGNEDBYCERT' ),
( N'VERSION' ),
( N'VIEW' ),
( N'WAITFOR' ),
( N'WHEN' ),
( N'WHENEVER' ),
( N'WHERE' ),
( N'WHILE' ),
( N'WIDTH_BUCKET' ),
( N'WINDOW' ),
( N'WITH' ),
( N'WITHIN' ),
( N'WITHIN GROUP' ),
( N'WITHOUT' ),
( N'WORK' ),
( N'WRITE' ),
( N'WRITETEXT' ),
( N'XACT_STATE' ),
( N'xml' ),
( N'XMLAGG' ),
( N'XMLATTRIBUTES' ),
( N'XMLBINARY' ),
( N'XMLCAST' ),
( N'XMLCOMMENT' ),
( N'XMLCONCAT' ),
( N'XMLDOCUMENT' ),
( N'XMLELEMENT' ),
( N'XMLEXISTS' ),
( N'XMLFOREST' ),
( N'XMLITERATE' ),
( N'XMLNAMESPACES' ),
( N'XMLPARSE' ),
( N'XMLPI' ),
( N'XMLQUERY' ),
( N'XMLSERIALIZE' ),
( N'XMLTABLE' ),
( N'XMLTEXT' ),
( N'XMLVALIDATE' ),
( N'YEAR' ),
( N'ZONE' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment