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

update data in a column 1

Status
Not open for further replies.

cduncan

Technical User
Mar 28, 2005
4
US
Its been a good while since I've written SQL and I need to update a column of SSN that do not have dashes to contain dashes. The field is a varchar so I need to go from '123456789' to '123-45-6789'. Any help greatly appreciated!!!
 
Why do you need to update the field? If you need to display it or print it with that format then you can always format it during the select itself.

Anyway you would do a update tbl set fld = "expression" where expression will depend on your DB.

Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
select number from ems.technician t
where last_name = 'Bosch'
[the result is 056649129]

to change it to 056-64-9129...

update ems.technician t
set t.number = (%%% + '-' + %% + '-' + %%%%) where last_name = 'Bosch'


?????

What am I doing wrong? If I could only import it from the text file I did it successfully with from Excel!!!
 
Set t.number = substr(ss,1,3) || '-' || substr(ss,4,2) || '-' || substr(ss,6,4)

should work
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top