|
|
Question : Update set
|
|
I need help with an update set statement
On the field postcode if the len(6) i.e. de34lf, after the 3rd character i need a ' ' so it would be de3 4lf And if the len(7), i.e. de443lf, after the 4the character i need a ' ' so it would be de44 3lf
How can this be done, rtim and ltrim will be required
|
Answer : Update set
|
|
Karinloos, len only does the rtrim function alone. hence doing ltrim is necessary.
update table set postcode = case len(ltrim(postcode)) when 6 then left(ltrim(postcode), 3) + ' ' + replace(postcode, left(ltrim(postcode), 3),'') when 7 then left(ltrim(postcode), 4) + ' ' + replace(postcode, left(ltrim(postcode), 4),'') else postcode end
i think this will be sufficient.
|
|
|
|
|