Logo 
Search:

SQL Server Articles

Submit Article
Home » Articles » SQL Server » String FunctionsRSS Feeds

QUOTENAME Function

Posted By: Sarita Patel     Category: SQL Server     Views: 14050

This article explains QUOTENAME function of sql server with examples.

QUOTENAME is used to add delimiters to make the specified string a valid sql server delimiter identifier. 


Syntax of QUOTENAME Function :

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

character_string is a string to add delimiters.

quote_character is optional. It can be single quote ( ' ) , double quote ( " )  or square brackets ( [or] ). If you don't specify quote_character, it takes square brackets by default.

It returns nvarchar(258) data type.


Examples of QUOTENAME Function :

Example 1 : Use of QUOTENAME function in select clause

* Delimiting string using double quote.

SELECT QUOTENAME('Syntax-Example','"')

Output
"Syntax-Example"

Above example returns delimited string with double quote.


* Delimiting string using single quote

SELECT QUOTENAME('Syntax-Example','''')

Output
'Syntax-Example'

Above example returns delimited string with single quote.


* Delimiting string using default value square brackets.

SELECT QUOTENAME('Syntax-Example')

Output
[Syntax-Example]

Above example returns default delimited string with square brackets.


  
Share: 

 
 
 

Didn't find what you were looking for? Find more on QUOTENAME Function Or get search suggestion and latest updates.

Sarita Patel
Sarita Patel author of QUOTENAME Function is from United States.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!