I have to convert int to varchar and need to take care about one more consideration.
For example:
1)My string length is always 10 characters. (i.e. "0000000001")
Whenever I generated a new id, it has to increment (i.e. "0000000002")
When it reaches the 10th string will be "0000000010", etc...
I have no idea how to implement this.
trying as a first step.
--Declared variable to increment count
declare @CTR INT
--@LIPRequestID is integer this is what i have to add to my
declare @LIPRequestID int
select @LIPRequestID=0
declare @LIPRequestIDstring varchar(max)
select @ctr=0
WHILE @CTR<2
BEGIN
select @ctr=@ctr+1
select @LIPRequestID=@LIPRequestID+1
select @LIPRequestIDstring='00000000'+ CAST(@LIPRequestID AS VARCHAR(10)
print @LIPRequestIDstring
END
but it is throwing the following exception error:
Msg 102, Level 15, State 1, Line 14 Incorrect syntax near '@LIPRequestIDstring'.
can anybody suggest where I am going wrong?