Link to home
Start Free TrialLog in
Avatar of andyw27
andyw27

asked on

Inserting SQL

Hi,

I have two separate databases.  DB01 and DB02

DB01 contains data that is not present in DB02 and the task here is to get data from DB01 into DB02.

I have so far written an SQL statement to get the data that I need displayed.  Can this be easily turned into the relevant insert statements?

Any other suggestions appreciated.  I’m using SQL Server  Management Studio?

Thanks in advance.
Avatar of sameer_goyal
sameer_goyal
Flag of India image

Hi,

I am sure i can help. But I will need a sample query that you have to displaying the data.

I can then quickly give you an equivalent insert query.

Also, help me understand if both the databases are on the same server?
ASKER CERTIFIED SOLUTION
Avatar of Peter Kiprop
Peter Kiprop
Flag of Kenya image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Olaf Doschke
As you already have a query displaying the data you want in db02, just make sure it has all fields in the table field order and you can do

insert into db02.dbo.table
(....your select from db01.dbo.table here...)

The only other prerequisite is both databases are on the same server instance, so you can address the tables as db01.dbo.table and db02.dbo.table.

Bye, Olaf.