MS Access 2000 Leading zeros
Is there a way of adding and storing leading zeros to a number in a table field without them being entered?
ie; 7001 to be stored as 007001 and
35035 stored as 035035
Software
Is there a way of adding and storing leading zeros to a number in a table field without them being entered?
ie; 7001 to be stored as 007001 and
35035 stored as 035035
by jonb Accepted solution
by tony hopkinson Accepted solution
You'll need to make the column a char type if you want to store it, or you could just do it on output.
select replicate('0',6 - DataLength(Convert(VarChar(6),[myinteger]))) + Convert(VarChar(6),[myinteger])
from mytable
where [myinteger] = 7001
will give
007001 as the answer
Whether you do this on update or insert, or simply leave it for selecting, will depend mainly on convience I suspect.
This discussion is closed to new replies.
Sort by Trending