Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Sql query between 2 databases

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-09-12 : 10:49:15
Victor writes "We are currently running SQL 2000 on Windows 2000 Server machines with SP 1 and 2 respectively. The first database is our time and attendance system and the second is our payroll system. We need to copy data from the T & A to the Payroll database. That part is fine. The problem lies in that we need to delete any records in an import table in the payroll database that match certain criteria before the copy process runs.

The copy process is setup in a Stored procedure in the time and attendance database that is called from a VB program. My problem lies in how to reference to the payroll database from the time and attendance database to delete the records.

We do not have trusted connections between our servers, but I will be using the sa accounts to run the procedures."

joldham
Wiseass Yak Posting Master

300 Posts

Posted - 2002-09-12 : 13:02:51
Look up linked servers in BOL.

Jeremy

Go to Top of Page

motokevin
Starting Member

36 Posts

Posted - 2002-09-12 : 15:13:21
I've done something similar like this:

run this query on DB1, the OpenRowset will get the query from the other DB

Select DB2.col1, DB2.col2, DB2.col3
from OpenRowset('SQLOLEDB','SERVER_NAME';'USER_NAME';'PASSWORD','Select col1, col2, col3 From DATABASE_NAME.dbo.TABLE_NAME ') DB2

you can inner join the OpenRowset table on a table in the DB you run from

Go to Top of Page
   

- Advertisement -