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 2000 Forums
 SQL Server Development (2000)
 append a apostrophe to a field

Author  Topic 

akpaga
Constraint Violating Yak Guru

331 Posts

Posted - 2008-04-30 : 10:55:12
hi

i would like to append an apostrophe in front of a number while selecting it . How can i do it in the select statement.

Like
if i say select custnumber from customer it give result set as

23456
52345

but i want the result to show as
'2345
'5345
'2312

Thanks in advance

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-04-30 : 10:59:19
SELECT CHAR(39) + CAST(CustNumber, 4)
FROM Customer



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

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-04-30 : 11:01:04
SELECT '''' + CAST(LEFT(YourNumberField,4) AS varchar(4)) FROM YourTable

Go to Top of Page

akpaga
Constraint Violating Yak Guru

331 Posts

Posted - 2008-04-30 : 15:23:46
thank you all
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-05-02 : 06:20:19
Also refer
http://sqlblogcasts.com/blogs/madhivanan/archive/2008/02/19/understanding-single-quotes.aspx

Madhivanan

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

- Advertisement -