jaselee
asked on
Draw two tables from different database on a single SQL command?
How do I grab two database record and display them on a single go? For example I'm trying to draw two database userid + password.
1. Database01 - table name: user - column: userid/password
2. Database02 - table name: user - column: userid/password
Can I use view to pull both of the tables from different database and put them on a single SQL command? I tried but it keep coming with INNER JOIN function which I don't need. Any suggestions?
1. Database01 - table name: user - column: userid/password
2. Database02 - table name: user - column: userid/password
Can I use view to pull both of the tables from different database and put them on a single SQL command? I tried but it keep coming with INNER JOIN function which I don't need. Any suggestions?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
CREATE VIEW MyVIEW AS
SELECT userid, password
FROM Database01..user
UNION ALL
SELECT userid, password
FROM Database02..user
Now
Select * from MyView
SELECT userid, password
FROM Database01..user
UNION ALL
SELECT userid, password
FROM Database02..user
Now
Select * from MyView
Ex:
SELECT userid, password
FROM Database01.dbo.user
UNION ALL
SELECT userid, password
FROM Database02.dbo.user
OR you can use join !