title: "QUOTENAME (Transact-SQL) | Microsoft Docs" ms.custom: "" ms.date: "03/14/2017" ms.prod: "sql" ms.prod_service: "database-engine, sql-database, sql-data-warehouse, pdw" ms.service: "" ms.component: "t-sql|functions" ms.reviewer: "" ms.suite: "sql" ms.technology:
- "database-engine" ms.tgt_pltfrm: "" ms.topic: "language-reference" f1_keywords:
- "QUOTENAME_TSQL"
- "QUOTENAME" dev_langs:
- "TSQL" helpviewer_keywords:
- "delimited identifiers [SQL Server]"
- "input strings [SQL Server]"
- "Unicode [SQL Server], delimited identifiers"
- "QUOTENAME function"
- "valid identifiers [SQL Server]" ms.assetid: 34d47f1e-2ac7-4890-8c9c-5f60f115e076 caps.latest.revision: 35 author: "edmacauley" ms.author: "edmaca" manager: "craigg" ms.workload: "Active" monikerRange: ">= aps-pdw-2016 || = azuresqldb-current || = azure-sqldw-latest || >= sql-server-2016 || = sqlallproducts-allversions"
[!INCLUDEtsql-appliesto-ss2008-all-md]
Returns a Unicode string with the delimiters added to make the input string a valid [!INCLUDEssNoVersion] delimited identifier.
Transact-SQL Syntax Conventions
QUOTENAME ( 'character_string' [ , 'quote_character' ] )
'character_string'
Is a string of Unicode character data. character_string is sysname and is limited to 128 characters. Inputs greater than 128 characters return NULL.
'quote_character'
Is a one-character string to use as the delimiter. Can be a single quotation mark ( ' ), a left or right bracket ( [] ), or a double quotation mark ( " ). If quote_character is not specified, brackets are used.
nvarchar(258)
The following example takes the character string abc[]def and uses the [ and ] characters to create a valid [!INCLUDEssNoVersion] delimited identifier.
SELECT QUOTENAME('abc[]def');
[!INCLUDEssResult]
[abc[]]def]
(1 row(s) affected)
Notice that the right bracket in the string abc[]def is doubled to indicate an escape character.
The following example takes the character string abc def and uses the [ and ] characters to create a valid [!INCLUDEssNoVersion] delimited identifier.
SELECT QUOTENAME('abc def');
[!INCLUDEssResult]
[abc def]
(1 row(s) affected)
PARSENAME (Transact-SQL)
CONCAT (Transact-SQL)
CONCAT_WS (Transact-SQL)
FORMATMESSAGE (Transact-SQL)
REPLACE (Transact-SQL)
REVERSE (Transact-SQL)
STRING_AGG (Transact-SQL)
STRING_ESCAPE (Transact-SQL)
STUFF (Transact-SQL)
TRANSLATE (Transact-SQL)
String Functions (Transact-SQL)