Sqlserver
 sql >> Datenbank >  >> RDS >> Sqlserver

SQL-Abfragehilfe, um nicht übereinstimmende Datensätze aus zwei Tabellen zu erhalten

create table #one (id int,acc nvarchar(25))
insert into #one (id , acc) values(1,'one') 
insert into #one (id , acc) values(2,'two') 
insert into #one (id , acc) values(3,'three') 

create table #two (acct nvarchar(25),ids int)
insert into #two (acct,ids) values('one',1) 
insert into #two (acct,ids) values('two',3) 
insert into #two (acct,ids) values('four',4) 

select ids from #two EXCEPT select id from #one 

drop table #one 
drop table #two 

Testen Sie dieses hier