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.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2006-01-23 : 08:02:25
|
| Joe writes "Greetings,I have searched the Transact-SQL help file and have browsed this and other sites, but cannot find an answer to this.I don't want to alter the data from the table - I just want to display the selected SSN in a more reader-friendly format. The data is in 555443333 format, but I want it to show as 555-44-3333.Any way to do this in SQL Server 2000?TIA,Joe" |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-01-23 : 08:12:47
|
| Declare @SSN varchar(20)set @SSN='555443333'Select Left(@SSN,3)+'-'+Substring(@SSN,4,2)+'-'+Substring(@SSN,6,4) as SSNMadhivananFailing to plan is Planning to fail |
 |
|
|
blindman
Master Smack Fu Yak Hacker
2365 Posts |
Posted - 2006-01-23 : 09:39:29
|
| Yup....BUT.....formatting for display should really handled by your reporting tool or user interface, not the database server. |
 |
|
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2006-01-23 : 10:09:02
|
just to be different Declare @SSN varchar(20)set @SSN='555443333'Select stuff(stuff(@SSN,6,0,'-'),4,0,'-') as SSNCorey Co-worker on children "...when I have children, I'm going to beat them. Not because their bad, but becuase I think it would be fun ..." |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-01-24 : 00:41:34
|
Good to see you back Stuff Specialist Is Relocation over?MadhivananFailing to plan is Planning to fail |
 |
|
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2006-01-24 : 10:59:47
|
Thanks! Still working on the migration of servers and what not, but I am all moved in to my new house. I still don't have a good internet option though I've also been playing a bit o' chess on redhotpawn.com as well... can be distracting Corey Co-worker on children "...when I have children, I'm going to beat them. Not because their bad, but becuase I think it would be fun ..." |
 |
|
|
|
|
|
|
|