我有一个没有做我想做的查询,我不知道如何解决这个问题:
DECLARE @RoomMap TABLE
(ID int IDENTITY(1,1),
SourceRoom int,--> SourceRoomID
SourceSiteID int,
TargetRoom int, -->DemoRoomID
TargetSiteID int
)
INSERT INTO @RoomMap
(SourceRoom, SourceSiteID)
SELECT tblControls_Rooms.ID, @origSiteID
FROM tblControls_Rooms
WHERE SiteID = @OrigSiteID
INSERT INTO @RoomMap
(TargetRoom, TargetSiteID)
SELECT tblControls_Rooms.ID, @NewSiteID
FROM tblControls_Rooms
WHERE SiteID = @newSiteID
INSERT INTO DemoRoomMap
(DemoRoomID, SourceRoomID)
SELECT TargetRoom, SourceRoom
FROM @RoomMap
这是我运行时的 DemoRoomMap 表:
TargetRoom SourceRoom
332 2
333 3
334 4
335 5
336 6
337 9
338 10
我运行上述查询时的结果:
TargetRoom SourceRoom
NULL 1942
NULL 1943
NULL 1944
NULL 1945
NULL 1946
2025 NULL
2026 NULL
2027 NULL
2028 NULL
如您所见,有些NULL
值我真的不想插入!我怎样才能摆脱它们?