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

update command

Status
Not open for further replies.

twinsfan08

Technical User
Apr 26, 2005
4
US
I have data within a field that needs to have dashes added to it. For example: I have an entry 123456 within a field (the name is field2 within the SQL table) and I need to place dashes within 123456, specifically 12-34-56. How can I do this effectively?

Thanks!!
 
Is it ALWAYS 6 characters?

"...we both know I'm training to become a cagefighter...see what happens if you try 'n hit me..."
 
update table_name
set field2 = left(field2,2) + '-' + substring(field2,3,2) + '-' +right(field2,2)


rsshetty.
It's always in the details.
 
thanks! the field is not always going to be 6 chars but it will always have 19 digits in it but 24 chars.
Layout looks like this - 11-11-11-1111-11111-1111
 
rsshetty's answer is still correct - you just ened to extend it and use the appropriate number of SUBSTRINGS.

--James
 
Thanks JamesLean. That was going to be my reply. you took the words right out of my textbox :)

rsshetty.
It's always in the details.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top