我有一个站点表,其中每个站点的评级都在 1 到 4 之间,我还有一个容量表,我想在其中使用站点表中的评级添加开始日期,例如
评级为 1 的网站,开始日期应为 01/05/2010,结束日期为 30/09/2010
评级为 2 和 3 的网站,开始日期应为 01/04/2010,结束日期为 01 /11/2010
评级为 4 的网站开始日期应为 01/01/2010,结束日期应为 31/12/2010
我对前两列的帮助已经看到了下面的代码,我现在需要添加开始日期和结束日期。你能帮我吗?
USE OCCUPANCY
CREATE TABLE Cap1
(PitchType_Skey int,
Site_Skey int)
DECLARE @PitchType_Skey INT
DECLARE @Site_Skey INT
SET @PitchType_Skey = 1
SET @Site_Skey = 1
WHILE (@Site_Skey < 127)
BEGIN
IF @PitchType_Skey = 8
BEGIN
SET @PitchType_Skey = 1
SET @Site_Skey = @Site_Skey + 1
END
IF (@Site_Skey < 127)
BEGIN
INSERT INTO dbo.Cap1 (PitchType_Skey, Site_Skey)
SELECT @PitchType_Skey, @Site_Skey
END
SET @PitchType_Skey = @PitchType_Skey + 1
END