Hello all,
I have a table with reference numbers along with a number of other fields.
The ref numbers start with B and vary in length, 4 - 6 characters, but need to be 6 characters long.
If the ref is 4 characters in length, I need to add 00 after the B. This works fine
If the ref is 5 characters in length, I need to add 0 after the B. This works fine
The problem I have is updating the whole table depending on whether the ref is 4 or 5 characters long.
I have tried the following SQL and countless other variations but keep getting a syntax error.
Anyone have any ideas?
Thanks in advance
Gareth
I have a table with reference numbers along with a number of other fields.
The ref numbers start with B and vary in length, 4 - 6 characters, but need to be 6 characters long.
If the ref is 4 characters in length, I need to add 00 after the B. This works fine
Code:
SET ref = left(ref,1) & "00" & right(ref,3)
Code:
SET ref = left(ref,1) & "0" & right(ref,4)
I have tried the following SQL and countless other variations but keep getting a syntax error.
Code:
Update Test iif(len([ref])<5,SET ref = left(ref,1) & "00" & right(ref,3),iif(len([ref])<6,SET ref = left(ref,1) & "0" & right(ref,4),[ref]))
Thanks in advance
Gareth
Comment