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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding a '0' to start of SSN for LEN(SSN) = 8 1

Status
Not open for further replies.

eb24

Programmer
Dec 17, 2003
240
US
I have a field with SSNs in which some of these numbers are missing it's leading digit due to it being a zero (0) when this file was uploaded at one time.

How can I add a 0 to the front of this field?

I used the following code to find these values:
Code:
select *
from tblData
where len(ssn) = 8
Thanks in advance for any assistance!
 
update tblData
set ssn = '0' + ssn
where len(ssn) = 8

or more generally

update tblData
set ssn = right(replicate('0',9) + ssn, 9)
where len(ssn) <> 9


======================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
 
nigelrivett:

Thank you always for your quick solutions!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top