Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
shinelawrence
Starting Member
32 Posts |
Posted - 2014-04-29 : 00:49:25
|
Hi Everyone,I generated one random ID in sql based one Employee name, i generated but the zero doesn't come. EG:Employee Id : L001 it is the first id of starting letter 'L', again i created another id for starting letter 'L' it shows L2 only instead of L002. If I hotcode 00 is previously the after 99th record it shows L0100 instead of 'L100'. How to do. Please tell the solution.This is my example Query:DECLARE @fname varchar(20)set @fname='L099'select CONVERT(varchar(10),(SUBSTRING('L056',2,LEN(@fname))+1))SELECT SUBSTRING(@fname,1,1)+'0'+CONVERT(varchar(10),(SUBSTRING(@fname,2,LEN(@fname))+1)) FROM Aud_UserRegister WHERE FName ='Lawrence'Lawce |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
|
|
|