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 MohapatraPosted Aug 31, 2015, 3:11 AM
Khan Abrar AhmedPosted Aug 31, 2015, 4:30 AM
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 KhanPosted Aug 31, 2015, 4:20 AM
Manas MohapatraPosted Aug 31, 2015, 4:00 AM
Basit KhanPosted Aug 31, 2015, 3:50 AM