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)
 convert to string

Author  Topic 

ann
Posting Yak Master

220 Posts

Posted - 2008-02-06 : 15:46:39
I have a query that I need to concantenate a datetime and several int fields into varchars/string.

Can someone tell me how to convert the datetime and int field into strings/varchar?

Thanks

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-02-06 : 15:56:50
A simple

SELECT 'ABC' + CAST(Col1 AS VARCHAR(2)) + ':' + CONVERT(VARCHAR(10), GETDATE(), 112)
FROM Table1



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

ann
Posting Yak Master

220 Posts

Posted - 2008-02-06 : 16:10:54
thanks!
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-02-07 : 07:19:48
And as usual if you want to show them in front end application, do concatenation there

Madhivanan

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

- Advertisement -