日期:2014-05-17 浏览次数:20660 次
SELECT A.* FROM A
WHERE NOT EXISTS(
SELECT 1 FROM B WHERE B.ID=A.ID AND B.NAME=A.NAME
)
----------------------------
-- Author :DBA_Huangzj(發糞塗牆)
-- Date :2013-04-09 17:24:13
-- Version:
-- Microsoft SQL Server 2008 R2 (SP1) - 10.50.2500.0 (X64)
-- Jun 17 2011 00:54:03
-- Copyright (c) Microsoft Corporation
-- Enterprise Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1, v.721)
--
----------------------------
--> 测试数据:[A]
if object_id('[A]') is not null drop table [A]
go
create table [A]([ID] int,[Name] varchar(5),[Levels] int,[Flag] int)
insert [A]
select 1001,'Test',0,0 union all
select 1001,'Gust',0,0 union all
select 1001,'Gust',1,1 union all
select 1002,'Admin',0,0 union all
select 1003,'Test',0,0 union all
select 1004,'Test',0,0 union all
select 1005,'Gust',0,0 union all
select 1006,'Gust',1,1 union all
select 1007,'Admin',0,0 union all
select 1008,'Test',0,0
--> 测试数据:[B]
if object_id('[B]') is not null drop table [B]
go
create table [B]([ID] int,[Name] varchar(4),[SavePlace]&nb