Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 7129

INSERT and UPDATE data on Remote Server table

$
0
0

Hi,

I am trying to Insert and Update data on a remote server table. I don't want to create a linked server connection. below is what i want to have. Can someone please suggest me how can i achieve it. I am using sql server 2008.

SELECT * INTO OPENROWSET
(
'SQLOLEDB'
,'tstapp01';'sa';'*****'
,'select * into table1 FROM OPENROWSET(''''SQLOLEDB'''',''''172.29.211.12'''';''''sa'''';''''*****'''', ''''Select * from [databasename].dbo.[table2] with (nolock) '''')'''
)
UPDATE OPENROWSET
(
'SQLOLEDB'
,'tstapp01';'sa';'*****'
,'Update database1.dbo.[table1] set [column1] = s.[column1], [column2] = s.[column2] from database1.dbo.table2 s with (nolock) inner join database1.dbo.[table2] t with (nolock) on s.condition = t.condition OPTION (MAXDOP 1) ' 
)

Thanks


Viewing all articles
Browse latest Browse all 7129

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>