Help with website sql insert statement with two data sources

Is there a way, on one single sql statement, to insert data to one data source from another data source?

I will have the need to create  bunch of "duplicate" type buttons where you click a button and it will pull all the data from table A, Data source A and dump that data into Table B, data source B.

In the past I would just create a select statement on table A, data source A, then an insert statement on Table B, data source B with the resulting data from the first query.

However, i'm looking at thousands of fields here now and I'd prefer to not do that if possible.

both servers will be SQL, both at different physical locations, but with a VPN pipe between the two.
dzirkelbAsked:
Who is Participating?
 
Pawan KumarDatabase ExpertCommented:
USE [master]  
GO  
EXEC master.dbo.sp_addlinkedserver  
    @server = N'SRVR002\ACCTG',  
    @srvproduct=N'SQL Server' ;  
Go

From Ms, Try the above command, use ur servername
0
 
Pawan KumarDatabase ExpertCommented:
You can use

Select * into destinationtable from sourcetable

Or if the table already exists

Insert into destinationtable
Select * from sourcetable

Note- * can be replaced with columnnames
0
 
dzirkelbAuthor Commented:
The problem is source table and destination table are from two different SQL servers on two different windows servers.

For Access, I can link both tables and what you laid out works fine, but for classic asp / web applications, I need to define the data source and destination data source, which are different from one another.
0
 
Pawan KumarDatabase ExpertCommented:
For sql server we can create linked server between the 2 sources and use 4 partname like below

Insert into tablename
Select * from servername.databasename.schema.tablename
0
 
dzirkelbAuthor Commented:
That would be ideal.  How do I go about doing that?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.