|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Selecting Data from one DB and Inserting into another DBIs it possible to use a stored procedure to select data from one database and
insert the data into another database? The stored procedure would be located in the database from which the data would be selected. See "select" statement and four part names in BOL.
Example: use northwind go select orderid, customerid, orderdate into pubs.dbo.tmp from dbo.orders if object_id('pubs.dbo.tmp') is not null drop table pubs.dbo.tmp go AMB Show quote "Danny Cary" wrote: > Is it possible to use a stored procedure to select data from one database and > insert the data into another database? The stored procedure would be located > in the database from which the data would be selected. > > Yes, you just need to use the fully qualified name of the objects
insert into DataBaseA.dbo.TableA select blah from DatabaseB.dbo.TableB If it is on another server, it is something like this... insert into ServerName.DataBaseA.dbo.TableA select blah from ServerName.DatabaseB.dbo.TableB -- Show quoteRobbe Morris - 2004/2005 Microsoft MVP C# Earn money answering .NET Framework messageboard posts at EggHeadCafe.com. http://www.eggheadcafe.com/forums/merit.asp "Danny Cary" <Danny C***@discussions.microsoft.com> wrote in message news:B114B228-C312-4FB9-BCB2-EFE29739F751@microsoft.com... > Is it possible to use a stored procedure to select data from one database > and > insert the data into another database? The stored procedure would be > located > in the database from which the data would be selected. > > I'm ashamed. That was too easy.
Thanks so much for the quick response. I am new to the site and did not realize help was so easily available. Show quote :-) |
|||||||||||||||||||||||