Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can a View or SP include tables from multiple databases?

Status
Not open for further replies.

dgillz

Instructor
Mar 2, 2001
10,036
1
38
US
Is this doable? I am envisioning something like:

SELECT balance from database1.glbalfil.balance
UNION SELECT balance from database.glbalfil.balance....

The idea is to get GL account balances from multiple companies (databases) to facilitate a consolidated financial statement.



Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports

"If you have a big enough dictionary, just about everything is a word"
--Dave Barry
 
Yes you can do this

e.g.

select 'Company 1' as Company, GLCODE, AMOUNT from DB1..SQLTABLE

union all

Select 'Company 2' as Company, GLCODE, AMOUNT from DB2..SQLTABLE

 
you can get them from different servers as well, if the server is added as a linked server, and you use 4 part naming scheme...

--------------------
Procrastinate Now!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top