Reputation: 2418
i want to add two tables. But how should i distinguish that which entries is from which table?
col1
-----
a
b
c
1
2
3
The result should be:
col1 tablename
----------------
a table1
b "
c "
d table2
e "
f "
Upvotes: 0
Views: 363
Reputation: 43974
Select Table1.Col1, "Table1" as 'TableName'
From dbo.Table1
Union all
Select Table2.Col1, "Table2" as 'TableName'
From dbo.Table2
Upvotes: 2