0
我在SQL真新,但是這是我到目前爲止有:如何使用存儲過程在while循環中增加多個值?
Alter Procedure GetallSchedule(@ScreenKey INT,@ShowNo INT) As
BEGIN
--DECLARE @ScreenKey INT
--DECLARE @ShowNo INT
--Declare @j INT
--Declare @i INT
Insert into Schedule(Cineplex,
ScreenKey,ShowOrder,ShowNo,FilmKey,ShowDate,ShowTime)
Values (1,@ScreenKey,1,@ShowNo,100,GETDATE(),GETDATE())
SET @ShowNo = 1
SET @ScreenKey = 1
WHILE (@ScreenKey <=20)
BEGIN
WHILE (@ShowNo <=7)
BEGIN
Insert into Schedule(
Cineplex,
ScreenKey,ShowOrder,ShowNo,FilmKey,ShowDate,ShowTime)
Values (1,@ScreenKey,1,@ShowNo,100,GETDATE(),GETDATE())
SET @ShowNo = @ShowNo + 1
END
SET @ScreenKey = @ScreenKey + 1
END
END
go
--Execute GetallSchedule 'TUC'
在這裏,我需要插入值增加兩個Screenkey
和ShowNo
。我需要獲得20個屏幕的結果,每個顯示7個顯示