单循环语句
declare @i nvarchar(36)
declare @LOCNUM nvarchar(36),@OBJECTTYPE nvarchar(36),@LOCDESC nvarchar(60),@LOCSTATUS nvarchar(36),@LOCSTORESTATUS nvarchar(36),@LINE decimal(5,0),@LIE decimal(5,0),@LAYER decimal(5,0)
set @i=13
while @i<31
begin
set @LOCNUM='OME01_0011010'+@i+'00100'
set @OBJECTTYPE='TBuff'
set @LOCDESC='1巷道1行'+@i+'列1层'
set @LOCSTATUS='Normal'
set @LOCSTORESTATUS='Free'
set @LINE=1
set @LIE=@i
set @LAYER=1 INSERT INTO [WMSServer].[dbo].[TWMS_LOC]
([LOCNUM]
,[OBJECTTYPE]
,[LOCDESC]
,[LOCSTATUS]
,[LOCSTORESTATUS]
,[LINE]
,[LIE]
,[LAYER])
VALUES
(@LOCNUM
,@OBJECTTYPE
,@LOCDESC
,@LOCSTATUS
,@LOCSTORESTATUS
,@LINE
,@LIE
,@LAYER)
set @i=@i+1
end GO
多循环语句
truncate table [WMSServer].[dbo].[TWMS_LOC] /***清空所有表的数据内容***/ declare @i nvarchar(),@j nvarchar(),@k nvarchar()
declare @LOCNUM nvarchar(),@OBJECTTYPE nvarchar(),@LOCDESC nvarchar(),@LOCSTATUS nvarchar(),@LOCSTORESTATUS nvarchar(),@LINE decimal(,),@LIE decimal(,),@LAYER decimal(,)
set @i=
while @i<
begin
set @j=
while @j<
begin
set @k=
while @k<
begin
set @LOCNUM='OME01_0011'+@i+''+@j+''+@k+''
set @OBJECTTYPE='TBuff'
set @LOCDESC='1巷道'+@i+'行'+@j+'列'+@k+'层'
set @LOCSTATUS='Normal'
set @LOCSTORESTATUS='Free'
set @LINE=@i
set @LIE=@j
set @LAYER=@k
INSERT INTO [WMSServer].[dbo].[TWMS_LOC]
([LOCNUM]
,[OBJECTTYPE]
,[LOCDESC]
,[LOCSTATUS]
,[LOCSTORESTATUS]
,[LINE]
,[LIE]
,[LAYER])
VALUES
(@LOCNUM
,@OBJECTTYPE
,@LOCDESC
,@LOCSTATUS
,@LOCSTORESTATUS
,@LINE
,@LIE
,@LAYER)
set @k=@k+
end
set @j=@j+
end
set @i=@i+
end
GO