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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stored procedure for multiple DBs 1

Status
Not open for further replies.

smeyer56

IS-IT--Management
Joined
Oct 16, 2002
Messages
206
Location
US
can I create an SP that pulls data from one database into a tempDB then pulls data from another db into the same tempDB?
something like:

create procedure test as
create table ....

use db1
select into .....

use db2
select into ....


I am trying to combine sales rep information from five different companies into one table so I can create a report off of one complete table instead of five reports. i have the select statements created and working.

 
If the databases are on the same server, use the three-part name in your code instead of just the table name.

On different servers, use a four-part name, but they have to be set up as linked servers.


Questions about posting. See faq183-874
 
Note that you can set up a view that uses a UNION clause to join many tables together.

Then you can do a mere SELECT FROM ViewName.

-------------------------------------
A sacrifice is harder when no one knows you've made it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top