Friday, March 23, 2012

Query two databases on same machine

Hi
I have an SQL 2000 Server, with a number of Databases on it,
I would like to run a query which extracts data from one database and
stores it in another database, the databases have a column which is
the same in each called "AccNumber".
How does one link two databases in an SQL 2000 query.
Any information is appreciated.
Thanks
KimboINSERT dbname1.dbo.table1 (AccNumber)
SELECT AccNumber FROM dbname2.dbo.table2
HTH. Ryan
"Kimbo" <theozbuggaNOSPAM@.hotmail.com> wrote in message
news:6etpr1lqu3ji8h4cr01p59i2pmah3flmf8@.
4ax.com...
> Hi
> I have an SQL 2000 Server, with a number of Databases on it,
> I would like to run a query which extracts data from one database and
> stores it in another database, the databases have a column which is
> the same in each called "AccNumber".
> How does one link two databases in an SQL 2000 query.
> Any information is appreciated.
> Thanks
> Kimbo|||Hi,
You need to use the FQN for the tables
[ServerName].[DatabaseName].[Owner].[tableName]
regards LaRa
"Kimbo" <theozbuggaNOSPAM@.hotmail.com> wrote in message
news:6etpr1lqu3ji8h4cr01p59i2pmah3flmf8@.
4ax.com...
> Hi
> I have an SQL 2000 Server, with a number of Databases on it,
> I would like to run a query which extracts data from one database and
> stores it in another database, the databases have a column which is
> the same in each called "AccNumber".
> How does one link two databases in an SQL 2000 query.
> Any information is appreciated.
> Thanks
> Kimbo|||Kimbo
INSERT INTO DataBase_One.dbo.Table
SELECT <> FROM Database_Two.dbo.Table
"Kimbo" <theozbuggaNOSPAM@.hotmail.com> wrote in message
news:6etpr1lqu3ji8h4cr01p59i2pmah3flmf8@.
4ax.com...
> Hi
> I have an SQL 2000 Server, with a number of Databases on it,
> I would like to run a query which extracts data from one database and
> stores it in another database, the databases have a column which is
> the same in each called "AccNumber".
> How does one link two databases in an SQL 2000 query.
> Any information is appreciated.
> Thanks
> Kimbo|||use dbname1
go
insert dbname2.owner.table2(field)
select field from table1
Regards,
"Ryan" wrote:

> INSERT dbname1.dbo.table1 (AccNumber)
> SELECT AccNumber FROM dbname2.dbo.table2
> --
> HTH. Ryan
>
> "Kimbo" <theozbuggaNOSPAM@.hotmail.com> wrote in message
> news:6etpr1lqu3ji8h4cr01p59i2pmah3flmf8@.
4ax.com...
>
>|||Look up "distributed partitioned views" in Books Online. Based on your post
I
see no need for physically moving data from one database into another.
ML
http://milambda.blogspot.com/

No comments:

Post a Comment