SQL QUOTENAME Function

QUOTENAME adds delimiters to a string making it a valid SQL Server identifier.

The delimiter can be quotation mark, bracket, parentheses, and others.

Delimiters are added before and after the input string.

Example

#

Add square bracket delimiters to the given string.

SELECT QUOTENAME('Order') AS 'Table Name'
Result:  1 record
Table Name
[Order]

Syntax

Syntax of the QUOTENAME function.

QUOTENAME(string [,quote-character])

string -- a string with up to 128 characters.

quote-character -- optional. Characters to use as delimiters. Default is [].


More Examples

QUOTENAME with quote characters

Displays a string with different delimiters.
SELECT QUOTENAME('Order', '()') AS 'Parentheses',
       QUOTENAME('Order', '"') AS 'Double Quotes',
       QUOTENAME('Order', '{}') AS 'Curly Braces'
Result:  1 record
Parentheses Double Quotes Curly Braces
(Order) "Order" {Order}

You may also like



Guides


vsn 3.1