Click here to Skip to main content
15,908,776 members
Please Sign up or sign in to vote.
1.33/5 (2 votes)
See more:
I am having a server A and a linked server B. I want to insert data from Server A to Server B. In the same server i am able to do so.

Fetching is fine with Linked Server

:Select * from LinkedServerName.LinkedServerDB.LinkedServerSchema.LinkedServerTable

But how can I insert data from a server to a configured linked server.

What I have tried:

Select * from LinkedServerName.LinkedServerDB.LinkedServerSchema.LinkedServerTable

But how can I insert data from a server to a configured linked server. 
Posted
Updated 3-Oct-18 2:53am
Comments
scottgp 2-Oct-18 12:40pm    
You should just be able to insert normally, using the same naming convention, e.g.
INSERT INTO LinkedServerName.LinkedServerDB.LinkedServerSchema.LinkedServerTable
(column1)
VALUES
('test');

or select * into LinkedServerName.LinkedServerDB.LinkedServerSchema.LinkedServerTable from dbo.localtable;
[no name] 2-Oct-18 20:45pm    
if your linked server and db are correct, then your query should work with no issue. No special stuff needed to insert with linked server.

1 solution

Linked servers are simply servers that can be accessed from each other. There are several methods to do what you want. The simplest is to write two insert statements - one for each server's insert requirements.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900