Reputation: 43
I have two tables in SQL Server 2008 R2. One is called customer
and data in the table is like this:
The second table is called Operators
and data looks like this:
The result should combine data from both tables and look like this:
Upvotes: 0
Views: 46
Reputation: 1123
Please try this as well ..
SELECT BrID
,Customer_Id
,0 as Account_Id
,Customer_Name as [Customer name]
,NIC_No
FROM Customer
UNION ALL
select BrID
,Customer_Id
,Account_Id
,CONCAT(First_Name,' ',Last_Name) as [Customer name]
,NIC_No
FROM Operator
Upvotes: 0
Reputation: 1269483
I think you want union all
:
select brid, customer_id, 0 as account_id, customer_name, nic_no
from customers
union all
select brid, customer_id, account_id, (first_name + ' ' + last_name) as customer_name, nic_no
from operators;
Upvotes: 1