Skip to content

Commit 0fc6621

Browse files
Merge pull request #37031 from MicrosoftDocs/main
Auto Publish – main to live - 2026-04-09 17:30 UTC
2 parents e192d5a + 5db78ab commit 0fc6621

7 files changed

Lines changed: 324 additions & 210 deletions

File tree

docs/odbc/reference/syntax/sqlgetinfo-function.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,13 @@ SQLRETURN SQLGetInfo(
166166
SQL_MAX_CONCURRENT_ACTIVITIES
167167
SQL_MAX_DRIVER_CONNECTIONS
168168
SQL_ODBC_INTERFACE_CONFORMANCE
169-
SQL_ODBC_STANDARD_CLI_CONFORMANCE
170169
SQL_ODBC_VER
171170
SQL_PARAM_ARRAY_ROW_COUNTS
172171
SQL_PARAM_ARRAY_SELECTS
173172
SQL_ROW_UPDATES
174173
SQL_SEARCH_PATTERN_ESCAPE
175174
SQL_SERVER_NAME
175+
SQL_STANDARD_CLI_CONFORMANCE
176176
SQL_STATIC_CURSOR_ATTRIBUTES1
177177
SQL_STATIC_CURSOR_ATTRIBUTES2
178178
:::column-end:::

docs/relational-databases/databases/database-identifiers.md

Lines changed: 91 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ description: Get acquainted with database identifiers. Learn about their collati
44
author: WilliamDAssafMSFT
55
ms.author: wiassaf
66
ms.reviewer: randolphwest
7-
ms.date: 03/30/2026
7+
ms.date: 04/08/2026
88
ms.service: sql
99
ms.subservice: configuration
1010
ms.topic: concept-article
11+
ai-usage: ai-assisted
1112
ms.custom:
1213
- ignite-2025
1314
helpviewer_keywords:
@@ -26,73 +27,77 @@ monikerRange: ">=aps-pdw-2016 || =azuresqldb-current || =azure-sqldw-latest || >
2627

2728
[!INCLUDE [SQL Server Azure SQL Database Synapse Analytics PDW FabricSE FabricDW FabricSQLDB](../../includes/applies-to-version/sql-asdb-asdbmi-asa-pdw-fabricse-fabricdw-fabricsqldb.md)]
2829

29-
The database object name is referred to as its identifier.
30+
The database object name is its identifier.
3031

3132
Servers, databases, and database objects, such as tables, views, columns, indexes, triggers, procedures, constraints, and rules, can have identifiers. Most objects require identifiers, but some objects, such as constraints, make them optional.
3233

3334
You create an object identifier when you define the object. Use the identifier to reference the object. For example, the following statement creates a table with the identifier `TableX`, and two columns with the identifiers `KeyCol` and `Description`:
3435

3536
```sql
36-
CREATE TABLE TableX (
37+
CREATE TABLE TableX
38+
(
3739
KeyCol INT PRIMARY KEY,
38-
Description NVARCHAR(80)
40+
Description NVARCHAR (80)
3941
);
4042
```
4143

42-
This table also has an unnamed constraint. The primary key constraint has no identifier, and so would be assigned a system-generated name like `PK__TableX__D7CB9CCCEEF0806C`, which you could observe in system metadata views like `sys.key_constraints`.
44+
This table has an unnamed constraint. The primary key constraint has no user-specified identifier, so the system assigns it a generated name like `PK__TableX__D7CB9CCCEEF0806C`. You can see this name in system metadata views like [sys.key_constraints](../system-catalog-views/sys-key-constraints-transact-sql.md).
4345

4446
Constraint names and other schema-scoped objects must be unique within a database schema. For example, two primary key constraints can't share a name. However, column names only need to be unique within each table, not within the schema.
4547

46-
The collation of an identifier depends on the level at which you define it.
48+
The collation of an identifier depends on the level at which you define it.
49+
50+
- The default collation of the instance is assigned to identifiers of instance-level objects, such as logins and database names.
4751

48-
- The default collation of the instance is assigned to identifiers of instance-level objects, such as logins and database names.
4952
- The default collation of the database is assigned to identifiers of objects in a database, such as tables, views, and column names. For example, you can create two tables with names that differ only in case in a database that has case-sensitive collation, but you can't create them in a database that has case-insensitive collation.
5053

5154
> [!NOTE]
52-
> The names of variables, or the parameters of functions and stored procedures must comply with the rules for [!INCLUDE [tsql](../../includes/tsql-md.md)] identifiers.
55+
> The names of variables, or the parameters of functions and stored procedures, must comply with the rules for [!INCLUDE [tsql](../../includes/tsql-md.md)] identifiers.
5356
5457
## Classes of identifiers
5558

5659
There are two classes of identifiers:
5760

58-
- **Regular identifiers** comply with the rules for the format of identifiers. Regular identifiers aren't delimited when they're used in [!INCLUDE [tsql](../../includes/tsql-md.md)] statements.
61+
- **Regular identifiers** comply with the format rules for identifiers. They aren't delimited when used in [!INCLUDE [tsql](../../includes/tsql-md.md)] statements. Regular identifiers must follow the [rules for regular identifiers](#rules-for-regular-identifiers): they can only contain letters, digits, and certain symbols (`_`, `@`, `#`, `$`), must start with a letter or one of `_`, `@`, `#`, and can't be a reserved word.
5962

6063
```sql
61-
USE AdventureWorks2022;
64+
USE AdventureWorks2025;
6265
GO
6366

6467
SELECT *
6568
FROM HumanResources.Employee
6669
WHERE NationalIDNumber = 153479919;
6770
```
6871

69-
- **Delimited identifiers** are enclosed in double quotation marks (`"`) or brackets (`[` and `]`). Identifiers that comply with the rules for the format of identifiers might not be delimited. For example:
72+
- **Delimited identifiers** are enclosed in double quotation marks (`"`) or brackets (`[` and `]`). Delimiters allow you to use names that would otherwise be invalid as regular identifiers, such as reserved keywords, names with spaces, or names with special characters. Identifiers that already comply with the regular identifier rules can also be delimited, but the delimiters are optional in that case. For more information, see [Rules for delimited identifiers](#rules-for-delimited-identifiers).
7073

7174
```sql
72-
USE AdventureWorks2022;
75+
USE AdventureWorks2025;
7376
GO
7477

7578
SELECT *
7679
FROM [HumanResources].[Employee] --Delimiter is optional.
77-
WHERE [NationalIDNumber] = 153479919 --Delimiter is optional.
80+
WHERE [NationalIDNumber] = 153479919; --Delimiter is optional.
7881
```
7982

80-
Identifiers that don't comply with all the rules for identifiers must be delimited in a [!INCLUDE [tsql](../../includes/tsql-md.md)] statement. For example:
83+
Identifiers that don't comply with the rules for regular identifiers must be delimited in a [!INCLUDE [tsql](../../includes/tsql-md.md)] statement. For example:
8184

8285
```sql
83-
USE AdventureWorks2022;
86+
USE AdventureWorks2025;
8487
GO
8588

8689
--Identifier contains a space and uses a reserved keyword.
87-
CREATE TABLE [SalesOrderDetail Table] (
90+
CREATE TABLE [SalesOrderDetail Table]
91+
(
8892
[Order] INT NOT NULL,
89-
[SalesOrderDetailID] INT IDENTITY(1, 1) NOT NULL,
93+
[SalesOrderDetailID] INT IDENTITY (1, 1) NOT NULL,
9094
[OrderQty] SMALLINT NOT NULL,
9195
[ProductID] INT NOT NULL,
9296
[UnitPrice] MONEY NOT NULL,
9397
[UnitPriceDiscount] MONEY NOT NULL,
9498
[ModifiedDate] DATETIME NOT NULL,
95-
CONSTRAINT [PK_SalesOrderDetail_Order_SalesOrderDetailID] PRIMARY KEY CLUSTERED (
99+
CONSTRAINT [PK_SalesOrderDetail_Order_SalesOrderDetailID] PRIMARY KEY CLUSTERED
100+
(
96101
[Order] ASC,
97102
[SalesOrderDetailID] ASC
98103
)
@@ -106,6 +111,67 @@ WHERE [Order] = 10; --Identifier is a reserved keyword.
106111

107112
Both regular and delimited identifiers must contain from 1 through 128 characters. For local temporary tables, the identifier can have a maximum of 116 characters.
108113

114+
## Rules for delimited identifiers
115+
116+
Delimited identifiers are either enclosed in brackets (`[` and `]`) or double quotation marks (`"`). They can contain any combination of characters, including spaces, reserved keywords, and special characters that aren't allowed in regular identifiers.
117+
118+
### Bracket-delimited identifiers
119+
120+
Bracket-delimited identifiers are enclosed in square brackets (`[` and `]`). If the identifier itself contains a right bracket (`]`), escape it by doubling it (`]]`). A left bracket (`[`) doesn't require escaping.
121+
122+
For example, to create and query a table whose name contains brackets:
123+
124+
```sql
125+
-- Create a table with a ] character in its name.
126+
CREATE TABLE [My]]Table]
127+
(
128+
ID INT PRIMARY KEY
129+
);
130+
GO
131+
132+
-- Reference the table in a query.
133+
SELECT *
134+
FROM [My]]Table];
135+
GO
136+
```
137+
138+
The `QUOTENAME` function returns a valid bracket-delimited identifier for a given string and handles the escaping automatically:
139+
140+
```sql
141+
SELECT QUOTENAME('abc[]def');
142+
```
143+
144+
The previous example returns `[abc[]]def]`.
145+
146+
### Double-quote-delimited identifiers
147+
148+
Double-quote-delimited identifiers are enclosed in double quotation marks (`"`). If the identifier itself contains a double quotation mark, escape it by doubling it (`""`).
149+
150+
Double-quote delimiters require `SET QUOTED_IDENTIFIER ON` (the default for most connections). When `QUOTED_IDENTIFIER` is `OFF`, the [!INCLUDE [ssde-md](../../includes/ssde-md.md)] treats double-quoted strings as string literals instead of identifiers. For more information, see [SET QUOTED_IDENTIFIER](../../t-sql/statements/set-quoted-identifier-transact-sql.md).
151+
152+
For example, to create and query a table that uses reserved keywords as identifiers:
153+
154+
```sql
155+
SET QUOTED_IDENTIFIER ON;
156+
GO
157+
158+
-- Create a table using double-quote delimiters.
159+
CREATE TABLE "My Table"
160+
(
161+
"Order" INT NOT NULL,
162+
"Description" NVARCHAR (100)
163+
);
164+
GO
165+
166+
SELECT "Order",
167+
"Description"
168+
FROM "My Table";
169+
GO
170+
```
171+
172+
> [!NOTE]
173+
> `SET QUOTED_IDENTIFIER` doesn't affect bracket-delimited identifiers. Bracket delimiters always work regardless of the `QUOTED_IDENTIFIER` setting.
174+
109175
## Rules for regular identifiers
110176

111177
The names of variables, functions, and stored procedures must follow these rules for [!INCLUDE [tsql](../../includes/tsql-md.md)] identifiers.
@@ -116,7 +182,7 @@ The names of variables, functions, and stored procedures must follow these rules
116182

117183
- The underscore (`_`), at sign (`@`), or number sign (`#`).
118184

119-
Certain symbols at the beginning of an identifier have special meaning in [!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)]. A regular identifier that starts with the at sign always denotes a local variable or parameter and can't be used as the name of any other type of object. An identifier that starts with a number sign denotes a temporary table or procedure. An identifier that starts with double number signs (`##`) denotes a global temporary object. Although the number sign or double number sign characters can be used to begin the names of other types of objects, we don't recommend this practice.
185+
Certain symbols at the beginning of an identifier have special meaning in the [!INCLUDE [ssde-md](../../includes/ssde-md.md)]. A regular identifier that starts with the at sign always denotes a local variable or parameter and can't be used as the name of any other type of object. An identifier that starts with a number sign denotes a temporary table or procedure. An identifier that starts with double number signs (`##`) denotes a global temporary object. Although the number sign or double number sign characters can be used to begin the names of other types of objects, you should avoid this practice.
120186

121187
Some [!INCLUDE [tsql](../../includes/tsql-md.md)] functions have names that start with double at signs (`@@`). To avoid confusion with these functions, don't use names that start with `@@`.
122188

@@ -128,26 +194,26 @@ The names of variables, functions, and stored procedures must follow these rules
128194

129195
- The at sign (`@`), dollar sign (`$`), number sign (`#`), or underscore (`_`).
130196

131-
1. The identifier must not be a [!INCLUDE [tsql](../../includes/tsql-md.md)] reserved word. [!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)] reserves both the uppercase and lowercase versions of reserved words. When you use identifiers in [!INCLUDE [tsql](../../includes/tsql-md.md)] statements, delimit identifiers that don't comply with these rules by using double quotation marks or brackets. The words that are reserved depend on the database compatibility level. Set the database compatibility level by using the [ALTER DATABASE compatibility level](../../t-sql/statements/alter-database-transact-sql-compatibility-level.md) statement.
197+
1. The identifier must not be a [!INCLUDE [tsql](../../includes/tsql-md.md)] reserved word. The [!INCLUDE [ssde-md](../../includes/ssde-md.md)] reserves both the uppercase and lowercase versions of reserved words. When you use identifiers in [!INCLUDE [tsql](../../includes/tsql-md.md)] statements, delimit identifiers that don't comply with these rules by using double quotation marks or brackets. The words that are reserved depend on the database compatibility level. Set the database compatibility level by using the [ALTER DATABASE compatibility level](../../t-sql/statements/alter-database-transact-sql-compatibility-level.md) statement.
132198

133199
1. Don't use embedded spaces or special characters.
134200

135201
1. Don't use [Supplementary characters](../collations/collation-and-unicode-support.md#Supplementary_Characters).
136202

137-
When you use identifiers in [!INCLUDE [tsql](../../includes/tsql-md.md)] statements, delimit identifiers that don't comply with these rules by using double quotation marks or brackets.
138-
139-
Some rules for the format of regular identifiers depend on the database compatibility level.
203+
When you use identifiers in [!INCLUDE [tsql](../../includes/tsql-md.md)] statements, delimit identifiers that don't comply with these rules by using double quotation marks or brackets. Some of these rules vary depending on the database [compatibility level](../../t-sql/statements/alter-database-transact-sql-compatibility-level.md).
140204

141205
## Catalog collation in Azure SQL Database
142206

143-
You can't change or set the logical server collation on Azure SQL Database. However, you can configure each database's collations separately for data in the database and for catalog. The catalog collation determines the collation for system metadata, such as object identifiers. You can specify both collations independently when you [create the database in the Azure portal](/azure/azure-sql/database/single-database-create-quickstart?view=azuresql&preserve-view=true&tabs=azure-portal#create-a-single-database), in T-SQL with [CREATE DATABASE](../../t-sql/statements/create-database-transact-sql.md?view=azuresqldb-current&preserve-view=true#collation_name), or in PowerShell with [New-AzSqlDatabase](/powershell/module/az.sql/new-azsqldatabase).
207+
You can't change or set the logical server collation on Azure SQL Database. However, you can configure each database's collations separately for data in the database and for catalog. The catalog collation determines the collation for system metadata, such as object identifiers. You can specify both collations independently when you [create the database in the Azure portal](/azure/azure-sql/database/single-database-create-quickstart?view=azuresql&preserve-view=true&tabs=azure-portal#create-a-single-database), in Transact-SQL (T-SQL) with [CREATE DATABASE](../../t-sql/statements/create-database-transact-sql.md?view=azuresqldb-current&preserve-view=true#collation_name), or in PowerShell with [New-AzSqlDatabase](/powershell/module/az.sql/new-azsqldatabase).
144208

145209
For details and examples, see [CREATE DATABASE](../../t-sql/statements/create-database-transact-sql.md?view=azuresqldb-current&preserve-view=true#collation_name). Specify a collation for the database (`COLLATE`) and a catalog collation for system metadata and object identifiers (`CATALOG_COLLATION`).
146210

147211
## Catalog collation in SQL database in Microsoft Fabric
148212

149-
Currently, by default the collation of a SQL database in Fabric is `SQL_Latin1_General_CP1_CI_AS`, but this can be configured when deploying. The collation can't be updated after deployment. Collations on individual columns are supported. For more information on deployment options, see [Options to create a SQL database in Fabric](/fabric/database/sql/create-options).
213+
The default collation of a SQL database in Fabric is `SQL_Latin1_General_CP1_CI_AS`. You can configure a different collation at deployment time, but you can't change it after the database is created. Individual columns can use their own collations. For more information on deployment options, see [Options to create a SQL database in Fabric](/fabric/database/sql/create-options).
150214

151215
## Related content
152216

153217
- [Reserved Keywords (Transact-SQL)](../../t-sql/language-elements/reserved-keywords-transact-sql.md)
218+
- [SET QUOTED_IDENTIFIER (Transact-SQL)](../../t-sql/statements/set-quoted-identifier-transact-sql.md)
219+
- [QUOTENAME (Transact-SQL)](../../t-sql/functions/quotename-transact-sql.md)

0 commit comments

Comments
 (0)