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

Add a character to a field

Status
Not open for further replies.

Ed75

MIS
Joined
Sep 29, 2004
Messages
27
Location
US
I'm sure this is a stupid question but I've never done it before.

What I want to do is add a leading zero to all of the items in a field that start with a 9. Can anyone lend me a hand please?

 
RIGHT(100 + fieldname,2)

Remember when... everything worked and there was a reason for it?
 
try this...

update table
set field = case when left(ltrim(field), 1) = '9' then replicate('0', 1) + field
else cus_name end

...if your field is an integer, you'll need to wrap field with convert(varchar, field). If your intention is to only select data, obviously use select vs update.

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top