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.
Who is Participating?
Pawan KumarDatabase ExpertCommented:
USE [master]  
EXEC master.dbo.sp_addlinkedserver  
    @server = N'SRVR002\ACCTG',  
    @srvproduct=N'SQL Server' ;  

From Ms, Try the above command, use ur servername
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
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.
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
dzirkelbAuthor Commented:
That would be ideal.  How do I go about doing that?
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.