Problem adding extra 0s to the beginning of varchar
Posted on 2008-06-13
I have the following code in one of my SELECT statements:
case when Contact_Migration_Ref is not null then right('00000' + cast(Contact_Migration_Ref as varchar(5)),5) else Contact_Migration_Ref_ID end
Contact_Migration_Ref is being pulled in and has a value like 01234 or 00070 but the beginning 0s where being removed from my code so I added the section:
right('00000' + cast(Contact_Migration_Ref as varchar(5)),5)
into my code above (as is laid out) but this hasn;t helded att the starting 0s this time around for some reason...it's worked in the past.
Any ideas how I can rectify this problem?