Thursday, 1 March 2018

Get common records between two tables without using exist,in and not in sql server

create table #table1
(
  Id int Identity(1,1),
  Name nvarchar(50)
)


create table #table2
(
  Id int,
  Name nvarchar(50)
)


insert into #table1(Name) values('A'),('B'),('C')

insert into #table2(Id,Name) values(1,'A'),(3,'C')





select ID,Name from #table1 intersect select ID,Name from #table2







No comments:

Post a Comment