Greetings, I have a question regarding what I think is probably a fairly basic question but through a couple hours of trying various things (including cast, convert, and a host of others) I have been unable to come up with an answer.
For this example I have cut pertinent information out of the actual Query. I have a 3 position character field which I wish to add "1" too. I would like it to be represented as "001" before the addition and "002" after the addition;however in everything I have tried the leading zeros are dropped after the addition.
Sample:
Result(S)
@financialPartyID Field Display: 001
@financialPartyID Field Display: 2
Thanks
Rich
For this example I have cut pertinent information out of the actual Query. I have a 3 position character field which I wish to add "1" too. I would like it to be represented as "001" before the addition and "002" after the addition;however in everything I have tried the leading zeros are dropped after the addition.
Sample:
Code:
DECLARE @financialPartyID char(3)
SELECT @financialPartyID = '001'
print '@financialPartyID Field Display:'+@financialPartyID
SELECT @financialPartyID = cast(cast(@financialPartyID + 1 as numeric )as char(3))
print '@financialPartyID Field Display:'+@financialPartyID
Result(S)
@financialPartyID Field Display: 001
@financialPartyID Field Display: 2
Thanks
Rich