Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

Browse by Tags · View All
sql_server 217
t-sql 211
tsql 116
sqlserver 96
BRH 78
#SQLServer 66
#TSQL 56
SQL Server 34
function 11
SSMS 9

Archive · View All
August 2007 17
August 2010 8
June 2012 7
June 2011 7
November 2007 7
August 2012 6
May 2012 6
November 2011 6
August 2011 6
October 2011 6

Madhivanan's TSQL Blog

Beware of limitation of Quotename() function

Oct 11 2010 6:00AM by Madhivanan   

Quotename() function is used to return a unicode string with delimiters. A delimiter can be a single quote, double quote or braces ( or [.

select 
	quotename('test','''')  as single_quote,
	quotename('test','"') as double_quote,
	quotename('test','(') as brace,
	quotename('test','[') as sqaure_beace

The result is

single_quote double_quote brace    sqaure_beace
------------ ------------ -------- ------------
'test'       "test"       (test)   [test]

Consider the following example. A variable @display is used for a display purpose ie to show them as part of the resultset.

create table #t(data varchar(100))

insert into #t(data)
select 'test' union all
select 'testing' union all
select 'nothing' 

declare @sql varchar(1000), @display varchar(100), @data varchar(100)
select @display ='Reporting', @data='test'

select @display as display,data from #t where data=@data

The result is

display        data
------------   ------------
Reporting      test

What if a single should be appended to the value Reporting?. We can use this method

select ''''+@display+'''' as display,data from #t where data=@data 

The quotename can be used in this case

select quotename(@display,'''') as display,data from #t where data=@data 

But beware that the Quotename() function will not work if the input's length is more than 128 characters

Tags: t-sql, sql_server, tsql, BRH, #TSQL, #SQLServer, quotename,


Madhivanan
3 · 39% · 12430
1
 
0
Lifesaver
 
0
Refreshed
 
0
Learned
 
0
Incorrect



Submit

1  Comments  

  • It's restricted to 128 characters because the argument is SYSNAME, which is unicode 128 characters(256 bytes).

    commented on Nov 2 2010 8:32AM
    Peso
    99 · 2% · 527

Your Comment


Sign Up or Login to post a comment.

"Beware of limitation of Quotename() function" rated 5 out of 5 by 1 readers
Beware of limitation of Quotename() function , 5.0 out of 5 based on 1 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]