nick轩

导航

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

posted on 2012-03-08 12:02  nick轩  阅读(856)  评论(0编辑  收藏  举报