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)
 Query to dispaly string with quotes

Author  Topic 

Dinky
Starting Member

37 Posts

Posted - 2008-02-05 : 16:33:04
How can we have query return something like 'a' (with the quotes).

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-02-05 : 16:41:06
1) QUOTENAME function.
2) Add extra single quotes to the query.

SELECT	Number,
QUOTENAME(Number, ''''),
'''' + CAST(Number AS VARCHAR(12)) + ''''
FROM master..spt_values
WHERE Type = 'p'
AND Number < 5



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

Dinky
Starting Member

37 Posts

Posted - 2008-02-05 : 16:54:57
Great. Thanks Peso.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-02-06 : 01:08:31
And run this to understand how single quotes work

select '','''','''''','''''''',''''''''''

Madhivanan

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

- Advertisement -