QUOTENAME (Transact-SQL)

**APPLIES TO:** ![yes](media/yes.png)SQL Server (starting with 2008) ![yes](media/yes.png)Azure SQL Database ![yes](media/yes.png)Azure SQL Data Warehouse ![yes](media/yes.png)Parallel Data Warehouse

Returns a Unicode string with the delimiters added to make the input string a valid SQL Server delimited identifier.

Topic link icon Transact-SQL Syntax Conventions

Syntax

QUOTENAME ( 'character_string' [ , 'quote_character' ] )   

Arguments

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 ( [] ), a double quotation mark ( " ), a left or right parenthesis ( () ), a greater than or less than sign ( >< ), a left or right brace ( {} ) or a backtick ( ` ). NULL returns if an unacceptable character is supplied. If quote_character is not specified, brackets are used.

Return Types

nvarchar(258)

Examples

The following example takes the character string abc[]def and uses the [ and ] characters to create a valid SQL Server delimited identifier.

SELECT QUOTENAME('abc[]def');  

Here is the result set.

[abc[]]def]  
  
(1 row(s) affected)  

Notice that the right bracket in the string abc[]def is doubled to indicate an escape character.

Examples: [!INCLUDEssSDWfull] and [!INCLUDEssPDW]

The following example takes the character string abc def and uses the [ and ] characters to create a valid SQL Server delimited identifier.

SELECT QUOTENAME('abc def');   

Here is the result set.

[abc def]  
  
(1 row(s) affected)  

See Also

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)