DECLARE
@MissingRows int,
@InsertedRows int
SELECT *
FROM DistributionKey_Section
WHERE SectionID NOT IN (select siteid from Site where SiteTypeCodeID IN(8)) AND
DistributionKeyID NOT IN (SELECT DistributionKeyID FROM DistributionKey WHERE
UnitInclusive=1)
SET @MissingRows = @@ROWCOUNT
IF @MissingRows > 0
BEGIN
<Insert Statement/Logic>
SET @InsertedRows = @@ROWCOUNT
PRINT CAST(@InsertedRows as varchar(5)) + ' missing rows were detected and added'
IF @MissingRows <> @InsertedRows
BEGIN
RAISERROR('The number of rows inserted does not equal the number of rows missing', 16, 1)
END
END
ELSE
PRINT 'No Missing Rows Detected'
这应该让你指出正确的方向。我没有碰到插件,因为我不确定你想要插入什么以及在哪里。 –
thx,那很快。 –