larrydavid
Programmer
Hello, I've identified several fields where the length is one or two digits too short. Therefore, it has been decided that these numeric values are to be updated as follows:
If the length is 9-digits, add a new 0 which would be the new 3rd digit from the right.
If the length is 8-digits, add two new 0's which would be the new 2nd & 3rd digit from the right.
I can get this far:
I've been looking at SUBSTRING, CHARINDEX and PATINDEX to solve this but am not sure how to put this together. I've been trying to find examples in SQL books online and elsewhere but haven't had much success. If anyone could show me a quick example to get me started that would really help.
Thanks,
Larry
If the length is 9-digits, add a new 0 which would be the new 3rd digit from the right.
If the length is 8-digits, add two new 0's which would be the new 2nd & 3rd digit from the right.
I can get this far:
Code:
update test set field1 = ??? where len(field1) = 9
I've been looking at SUBSTRING, CHARINDEX and PATINDEX to solve this but am not sure how to put this together. I've been trying to find examples in SQL books online and elsewhere but haven't had much success. If anyone could show me a quick example to get me started that would really help.
Thanks,
Larry