日期:2014-05-17 浏览次数:20420 次
IF OBJECT_ID('Ta','U') IS NOT NULL DROP TABLE Ta CREATE TABLE Ta(A1 varchar(4),A2 varchar(4),A3 varchar(4)) INSERT INTO Ta(A1,A2,A3) SELECT '01','02','03' UNION ALL SELECT '01','03','04' UNION ALL SELECT '02','05','08' IF OBJECT_ID('Tb','U') IS NOT NULL DROP TABLE Tb CREATE TABLE Tb(B1 varchar(4),B2 varchar(4),B3 varchar(4)) INSERT INTO Tb(B1,B2,B3) SELECT '01','02','03' UNION ALL SELECT '01','07','09' UNION ALL SELECT '02','04','05' SELECT B1 , B2 , B3 FROM dbo.Tb B WHERE NOT EXISTS(SELECT TOP 1 1 FROM Ta WHERE A1 = B.B1 AND A2 = B.B2 AND A3 = B.B3) DROP TABLE Ta DROP TABLE Tb