Quotename() function in SQL Server.

Many times we come across the situation where we want to store strings in different formats in SQL Server.

Recently I get to know the fuction quotename(), is a SQL Server String function.

It accepts a String as input and returns string of a valid delimited identifier according to pattern given by us.

Below are some examples of this fuction with formatted output.

                          Query                                                              Output

select quotename('Pravin More')   --[Pravin More]

 

select quotename('Pravin [More]') -- [Pravin [More]]]

 

select quotename('Pravin More', '"') -- "Pravin More"

 

select quotename('Pravin More''s Name', '''') -- 'Pravin More''s Name'

 

select quotename('Pravin More', '''') -- 'Pravin More'

 

select quotename('Pravin More', '|') – NULL

 

Thanks You.

Ebook Download
View all
Learn
View all