Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 insert from sql table in one server to another

Author  Topic 

Mikehjun
Starting Member

24 Posts

Posted - 2010-08-17 : 15:39:06
There are two tables and I just want to insert new rows added in one table to another one. I can easily write t-sql when it is in same SQL database in same server however I don't know how to insert record from sql table in one server to sql table in another server.

please help.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

use GIS

set identity_insert GIS.dbo.xCustomer2 on

insert into GIS.dbo.xCustomer2 (CustomerID, CompanyName, FirstName, LastName, ModifiedDate)

(select *
from GIS.dbo.xCustomer4
where GIS.dbo.xCustomer4.CustomerID not in
(select GIS.dbo.xCustomer2.CustomerID from gis.dbo.xCustomer2))

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2010-08-17 : 15:40:16
You need to create a linked server.

See this

http://msdn.microsoft.com/en-us/library/aa213778(SQL.80).aspx
Go to Top of Page

Mikehjun
Starting Member

24 Posts

Posted - 2010-08-17 : 17:34:13
Could you help me for the syntax?

server2
name:201.11.111.222 (no DNS setup)
database name: GIS
table name: customer2
user id: GIS
password: password
Go to Top of Page

vaibhavktiwari83
Aged Yak Warrior

843 Posts

Posted - 2010-08-18 : 07:04:06
EXEC sp_addlinkedserver
@server = '201.11.111.222',
@srvproduct = 'SQL Server'


Vaibhav T

To walk FAST walk ALONE
To walk FAR walk TOGETHER
Go to Top of Page
   

- Advertisement -