fikir
Programmer
- Jun 25, 2007
- 86
I have three tables tbl1, tbl2 and tbl3, all having employee info
I want to bring all unique records across the table and insert them to a fouth table.
therefore my fourth table should look like
tbl4
id name
1 John
2 Merry
3 Larry
4 Barry
5 Bob
6 Kerry
any suggestion?
Thanks,
Code:
declare @tbl1 table (id int name varchar(20)
declare @tbl2 table (id int name varchar(20)
declare @tbl3 table (id int name varchar(20)
insert into @tbl1
select 1, 'John'
union all select 2, 'Merry'
union all select 3, 'Larry'
insert into @tbl1
select 1, 'John'
union all select 2, 'Merry'
union all select 4, 'Barry'
insert into @tbl1
select 4, 'Barry'
union all select 5, 'Bob'
union all select 6, 'Kerry'
I want to bring all unique records across the table and insert them to a fouth table.
therefore my fourth table should look like
tbl4
id name
1 John
2 Merry
3 Larry
4 Barry
5 Bob
6 Kerry
any suggestion?
Thanks,