Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 SINGLE QUOTES IN OUTPUT

Author  Topic 

doco
Yak Posting Veteran

77 Posts

Posted - 2012-09-06 : 12:33:16
I wish to have output from a query to have ' output '. How is this done?

SELECT ' + parcel_number + ' produces 'parcel_number' instead of the parcel_number enclosed in single quotes.

TIA

Education is what you have after you've forgotten everything you learned in school

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-09-06 : 12:38:51
select '''' + parcel_number + ''''

inside single quote, if you want to have another single quote then you can escape that with another single quote.
so you have 4 single quotes to get 1 single quote in the output.


Too old to Rock'n'Roll too young to die.
Go to Top of Page

doco
Yak Posting Veteran

77 Posts

Posted - 2012-09-06 : 13:01:01
Ah, yes! Guess I didn't go far enough. I tried ''' which is more intrinsic than ''''. Anyway thanks!

Education is what you have after you've forgotten everything you learned in school
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2012-09-13 : 05:09:02
This will explain in detail
http://beyondrelational.com/modules/2/blogs/70/posts/10827/understanding-single-quotes.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -