SQL Server2008R2循环语句
Posted 不积跬步,无以至千里;不积小流,无以成江海。任何业绩的质变都
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SQL Server2008R2循环语句相关的知识,希望对你有一定的参考价值。
单循环语句
declare @i int 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_00113303200102‘ set @OBJECTTYPE=‘TBuff‘ set @LOCDESC=‘1巷道11行10列2层‘ set @LOCSTATUS=‘Normal‘ set @LOCSTORESTATUS=‘Free‘ set @LINE=1 set @[email protected] 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 @[email protected]+1 end GO
多循环语句
truncate table [WMSServer].[dbo].[TWMS_LOC] //清空表的所有数据内容 declare @i nvarchar(36),@j nvarchar(36),@k nvarchar(36),@n 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=1 set @n=101 while @i<33 begin set @j=13 while @j<31 begin set @k=1 while @k<3 begin set @LOCNUM=‘OME01_00113303200‘+@n set @OBJECTTYPE=‘TBuff‘ set @LOCDESC=‘1巷道‘[email protected]+‘行‘[email protected]+‘列‘[email protected]+‘层‘ 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 @[email protected]+1 end set @[email protected]+1 end set @[email protected]+1 end GO
以上是关于SQL Server2008R2循环语句的主要内容,如果未能解决你的问题,请参考以下文章
sql server 2008 r2:当前会计年度 where 子句中的 case 语句