| title | QUOTENAME (Transact-SQL) | Microsoft Docs | |||||
|---|---|---|---|---|---|---|
| ms.custom | ||||||
| ms.date | 03/14/2017 | |||||
| ms.prod | sql-non-specified | |||||
| ms.reviewer | ||||||
| ms.suite | ||||||
| ms.technology |
|
|||||
| ms.tgt_pltfrm | ||||||
| ms.topic | language-reference | |||||
| f1_keywords |
|
|||||
| dev_langs |
|
|||||
| helpviewer_keywords |
|
|||||
| ms.assetid | 34d47f1e-2ac7-4890-8c9c-5f60f115e076 | |||||
| caps.latest.revision | 35 | |||||
| author | BYHAM | |||||
| ms.author | rickbyh | |||||
| manager | jhubbard |
[!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
-- Syntax for SQL Server, Azure SQL Database, Azure SQL Data Warehouse, Parallel Data Warehouse
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)