Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

How to insert Data from a function on server A into a table on Server B.

$
0
0
Hi,

I have a function which is like this


DECLARE @oldmax bigint, @newmax bigint

SELECT @oldmax = max(exportTimestamp) FROM EXPORT_TIMESTAMPS
      
IF @oldmax IS NULL
SET @oldmax = 0
                  
SELECT * FROM ServerA.TableA.fnExportTrafficTS(@oldmax) ORDER BY storeID, TrafDate

SELECT @newmax = max(timestamp) FROM TRAFFIC t
      
IF @newmax > @oldmax
INSERT INTO EXPORT_TIMESTAMPS
VALUES(@newmax, GETDATE())


And now i need to insert the data coming out of this function into ServerB Table B


And the column names and everything coming out of the function is the same columns in Table B.So, no need to worry there.

I have never worked with inserting data from function through linked server.

Can someone please help me with this?

Thanks,
Sujith

Viewing all articles
Browse latest Browse all 23857

Trending Articles



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