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
 General SQL Server Forums
 New to SQL Server Programming
 sql script to format data ?

Author  Topic 

jooorj
Posting Yak Master

126 Posts

Posted - 2011-04-24 : 18:42:56
suppose i have the following output: 42001230 and I want to format it like :4200-1-2-30
or other : 20110112 >> to >> 20-11-011-2
thank you

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-04-24 : 18:46:22
Probably more natural in a client but

':' + stuff(stuff(stuff(convert(varchar(8),42001230),7,0,'-'),6,0,'-'),5,0,'-')


==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2011-04-24 : 20:28:49
Dupe: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=159842
Go to Top of Page
   

- Advertisement -