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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
SQL

From novice to tech pro — start learning today.