What i When Call being enter CallNumber should genrate 000001 so on depend upon CallNo.
I used in computed Column Specification Formula, ('00000'+right(CONVERT([nvarchar](250),[CallNo],(0)),(5)))
If CallNo=1 then i shows 000001
but if Call No=100 then shows 00000100
digit are increase. i do'nt want to increase digit
if Call No=100 then i shows 000100
how to do it in SQL.
Thanks
Basit.

Manas MohapatraRank #182 · 13.2K reputationPosted Aug 30, 2015, 11:11 PM EDT
Manas MohapatraRank #182 · 13.2K reputationPosted Aug 31, 2015, 12:00 AM EDT
Khan Abrar AhmedRank #778 · 3K reputationPosted Aug 31, 2015, 12:30 AM EDT
declare @call varchar(64) =10 --Input parameter
BEGIN
DECLARE @length INT
DECLARE @result VARCHAR(128)
SET @result = ''
SET @length = 0
DECLARE @appendZero VARCHAR(5)
SET @appendZero = '000000'
SET @length = Len(ltrim(rtrim(@call)))
DECLARE @i INT
SET @i = 1
IF (@length > 0)
BEGIN
WHILE (@i != 5)
BEGIN
IF (@length = @i)
SET @result = Substring(@appendZero, 0, (6 - @i))
SET @i = @i + 1
END
END
SET @result = @result + @call
select 'UR-'+@result
END
Basit KhanRank #4,768 · 326 reputationPosted Aug 30, 2015, 11:50 PM EDT
Basit KhanRank #4,768 · 326 reputationPosted Aug 31, 2015, 12:20 AM EDT