SQL Server 循环,左侧不足位补零
declare @i int
set @i=1
while @i <101
begin
INSERT INTO [TMS_V4].[dbo].[TB_GPSDeviceInfo]
([DeviceCode]
,[CompanyCode]
,[Status]
,[Remarks]
,[CreateUserName]
,[CreateBy]
,[CreateOn])
select 'KLD'+right('000'+ltrim(@i),3) ,'SZKLD',1,'','SYSTEM','SYSTEM',GETDATE()
set @i = @i+1
end