f)\\b",
			"name": "support.function.expression.sql"
		},
		{
			"match": "(?<!@)@@(?i)\\b(cursor_rows|connections|cpu_busy|datefirst|dbts|error|fetch_status|identity|idle|io_busy|langid|language|lock_timeout|max_connections|max_precision|nestlevel|options|packet_errors|pack_received|pack_sent|procid|remserver|rowcount|servername|servicename|spid|textsize|timeticks|total_errors|total_read|total_write|trancount|version)\\b",
			"name": "support.function.globalvar.sql"
		},
		{
			"match": "(?i)\\b(choose|iif)\\b",
			"name": "support.function.logical.sql"
		},
		{
			"match": "(?i)\\b(abs|acos|asin|atan|atn2|ceiling|cos|cot|degrees|exp|floor|log|log10|pi|power|radians|rand|round|sign|sin|sqrt|square|tan)\\b",
			"name": "support.function.mathematical.sql"
		},
		{
			"match": "(?i)\\b(app_name|applock_mode|applock_test|assemblyproperty|col_length|col_name|columnproperty|database_principal_id|databasepropertyex|db_id|db_name|file_id|file_idex|file_name|filegroup_id|filegroup_name|filegroupproperty|fileproperty|fulltextcatalogproperty|fulltextserviceproperty|index_col|indexkey_property|indexproperty|object_definition|object_id|object_name|object_schema_name|objectproperty|objectpropertyex|original_db_name|parsename|schema_id|schema_name|scope_identity|serverproperty|stats_date|type_id|type_name|typeproperty)\\b",
			"name": "support.function.metadata.sql"
		},
		{
			"match": "(?i)\\b(rank|dense_rank|ntile|row_number)\\b",
			"name": "support.function.ranking.sql"
		},
		{
			"match": "(?i)\\b(opendatasource|openrowset|openquery|openxml)\\b",
			"name": "support.function.rowset.sql"
		},
		{
			"match": "(?i)\\b(certencoded|certprivatekey|current_user|database_principal_id|has_perms_by_name|is_member|is_rolemember|is_srvrolemember|original_login|permissions|pwdcompare|pwdencrypt|schema_id|schema_name|session_user|suser_id|suser_sid|suser_sname|system_user|suser_name|user_id|user_name)\\b",
			"name": "support.function.security.sql"
		},
		{
			"match": "(?i)\\b(ascii|char|charindex|concat|difference|format|left|len|lower|ltrim|nchar|nodes|patindex|quotename|replace|replicate|reverse|right|rtrim|soundex|space|str|string_agg|string_escape|string_split|stuff|substring|translate|trim|unicode|upper)\\b",
			"name": "support.function.string.sql"
		},
		{
			"match": "(?i)\\b(binary_checksum|checksum|compress|connectionproperty|context_info|current_request_id|current_transaction_id|decompress|error_line|error_message|error_number|error_procedure|error_severity|error_state|formatmessage|get_filestream_transaction_context|getansinull|host_id|host_name|isnull|isnumeric|min_active_rowversion|newid|newsequentialid|rowcount_big|session_context|session_id|xact_state)\\b",
			"name": "support.function.system.sql"
		},
		{
			"match": "(?i)\\b(patindex|textptr|textvalid)\\b",
			"name": "support.function.textimage.sql"
		},
		{
			"captures": {
				"1": {
					"name": "constant.other.database-name.sql"
				},
				"2": {
					"name": "constant.other.table-name.sql"
				}
			},
			"match": "(\\w+?)\\.(\\w+)"
		},
		{
			"include": "#strings"
		},
		{
			"include": "#regexps"
		},
		{
			"captures": {
				"1": {
					"name": "punctuation.section.scope.begin.sql"
				},
				"2": {
					"name": "punctuation.section.scope.end.sql"
				}
			},
			"comment": "Allow for special ↩ behavior",
			"match": "(\\()(\\))",
			"name": "meta.block.sql"
		}
	],
	"repository": {
		"comments": {
			"patterns": [
				{
					"begin": "(^[ \\t]+)?(?=--)",
					"beginCaptures": {
						"1": {
							"name": "punctuation.whitespace.comment.leading.sql"
						}
					},
					"end": "(?!\\G)",
					"patterns": [
						{
							"begin": "--",
							"beginCaptures": {
								"0": {
									"name": "punctuation.definition.comment.sql"
								}
							},
							"end": "\\n",
							"name": "comment.line.double-dash.sql"
						}
					]
				},
				{
					"begin": "(^[ \\t]+)?(?=#)",
					"beginCaptures": {
						"1": {
							"name": "punctuation.whitespace.comment.leading.sql"
						}
					},
					"end": "(?!\\G)",
					"patterns": []
				},
				{
					"begin": "/\\*",
					"captures": {
						"0": {
							"name": "punctuation.definition.comment.sql"
						}
					},
					"end": "\\*/",
					"name": "comment.block.c"
				}
			]
		},
		"regexps": {
			"patterns": [
				{
					"begin": "/(?=\\S.*/)",
					"beginCaptures": {
						"0": {
							"name": "punctuation.definition.string.begin.sql"
						}
					},
					"end": "/",
					"endCaptures": {
						"0": {
							"name": "punctuation.definition.string.end.sql"
						}
					},
					"name": "string.regexp.sql",
					"patterns": [
						{
							"include": "#string_interpolation"
						},
						{
							"match": "\\\\/",
							"name": "constant.character.escape.slash.sql"
						}
					]
				},
				{
					"begin": "%r\\{",
					"beginCaptures": {
						"0": {
							"name": "punctuation.definition.string.begin.sql"
						}
					},
					"comment": "We should probably handle nested bracket pairs!?! -- Allan",
					"end": "\\}",
					"endCaptures": {
						"0": {
							"name": "punctuation.definition.string.end.sql"
						}
					},
					"name": "string.regexp.modr.sql",
					"patterns": [
						{
							"include": "#string_interpolation"
						}
					]
				}
			]
		},
		"string_escape": {
			"match": "\\\\.",
			"name": "constant.character.escape.sql"
		},
		"string_interpolation": {
			"captures": {
				"1": {
					"name": "punctuation.definition.string.begin.sql"
				},
				"3": {
					"name": "punctuation.definition.string.end.sql"
				}
			},
			"match": "(#\\{)([^\\}]*)(\\})",
			"name": "string.interpolated.sql"
		},
		"strings": {
			"patterns": [
				{
					"captures": {
						"2": {
							"name": "punctuation.definition.string.begin.sql"
						},
						"3": {
							"name": "punctuation.definition.string.end.sql"
						}
					},
					"comment": "this is faster than the next begin/end rule since sub-pattern will match till end-of-line and SQL files tend to have very long lines.",
					"match": "(N)?(')[^']*(')",
					"name": "string.quoted.single.sql"
				},
				{
					"begin": "'",
					"beginCaptures": {
						"0": {
							"name": "punctuation.definition.string.begin.sql"
						}
					},
					"end": "'",
					"endCaptures": {
						"0": {
							"name": "punctuation.definition.string.end.sql"
						}
					},
					"name": "string.quoted.single.sql",
					"patterns": [
						{
							"include": "#string_escape"
						}
					]
				},
				{
					"captures": {
						"1": {
							"name": "punctuation.definition.string.begin.sql"
						},
						"2": {
							"name": "punctuation.definition.string.end.sql"
						}
					},
					"comment": "this is faster than the next begin/end rule since sub-pattern will match till end-of-line and SQL files tend to have very long lines.",
					"match": "(`)[^`\\\\]*(`)",
					"name": "string.quoted.other.backtick.sql"
				},
				{
					"begin": "`",
					"beginCaptures": {
						"0": {
							"name": "punctuation.definition.string.begin.sql"
						}
					},
					"end": "`",
					"endCaptures": {
						"0": {
							"name": "punctuation.definition.string.end.sql"
						}
					},
					"name": "string.quoted.other.backtick.sql",
					"patterns": [
						{
							"include": "#string_escape"
						}
					]
				},
				{
					"captures": {
						"1": {
							"name": "punctuation.definition.string.begin.sql"
						},
						"2": {
							"name": "punctuation.definition.string.end.sql"
						}
					},
					"comment": "this is faster than the next begin/end rule since sub-pattern will match till end-of-line and SQL files tend to have very long lines.",
					"match": "(\")[^\"#]*(\")",
					"name": "string.quoted.double.sql"
				},
				{
					"begin": "\"",
					"beginCaptures": {
						"0": {
							"name": "punctuation.definition.string.begin.sql"
						}
					},
					"end": "\"",
					"endCaptures": {
						"0": {
							"name": "punctuation.definition.string.end.sql"
						}
					},
					"name": "string.quoted.double.sql",
					"patterns": [
						{
							"include": "#string_interpolation"
						}
					]
				},
				{
					"begin": "%\\{",
					"beginCaptures": {
						"0": {
							"name": "punctuation.definition.string.begin.sql"
						}
					},
					"end": "\\}",
					"endCaptures": {
						"0": {
							"name": "punctuation.definition.string.end.sql"
						}
					},
					"name": "string.other.quoted.brackets.sql",
					"patterns": [
						{
							"include": "#string_interpolation"
						}
					]
				}
			]
		}
	}
}