Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL View S.S. Number

Status
Not open for further replies.

mtorpy

MIS
Aug 20, 2002
31
US
Is there a way to display a social security number stored in a single field and format it?

Stored : 522219635

Display: 522-21-9635

In Crystal Reports I can use:
Left ({UPR00100.SOCSCNUM},3)+'-'+Mid ({UPR00100.SOCSCNUM},4 ,2 )+'-'+Right ({UPR00100.SOCSCNUM},4 )

But I don't beliew SQL allows for this operator.

Any help would be great
- Matt
 
In addition to using the Substring function in place of the Mid function, you can use the Stuff function to insert the dashes in the string.

Stuff(Stuff(UPR00100.SOCSCNUM,6,0,'-'),4,0,'-') Terry L. Broadbent - DBA
SQL Server Page:
If you want to get the best answer for your question read faq183-874.
 
Just a reminder. Some SSN's have one or more leading zeros.

You didn't specify that the column was defined as CHAR(9). If so, all is well. If not (e.g. defined as INT) then a little more is needed to restore the leading zero character(s).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top