amillyard
asked on
sql table record copy
MS SQL Server 2008
How do you script via a Stored Procedure the following:
DB 1 - Table 1A (server A)
DB 2 - Table 2A (server B)
if DB 1 - Table 1A (column1) - unique value (uniqueidentity) doe not exist in
DB 2 - Table 2A (column1) - unique value (uniqueidentity) then create it in DB 2 - Table 2A
then copy certain columns from DB 1 - Table 1A to DB 2 - Table 2A (insert a new entry).
(there could for example none, 1 or 1000's of new table entries to create/insert each time stored procedure is called)
How do you script via a Stored Procedure the following:
DB 1 - Table 1A (server A)
DB 2 - Table 2A (server B)
if DB 1 - Table 1A (column1) - unique value (uniqueidentity) doe not exist in
DB 2 - Table 2A (column1) - unique value (uniqueidentity) then create it in DB 2 - Table 2A
then copy certain columns from DB 1 - Table 1A to DB 2 - Table 2A (insert a new entry).
(there could for example none, 1 or 1000's of new table entries to create/insert each time stored procedure is called)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
you can create a linked server like the one below
EXEC sp_addlinkedserver
@server='lsserverA',
@srvproduct='',
@provider='SQLNCLI',
@datasrc='Server1.abc.com\ DB1'
EXEC sp_addlinkedserver
@server='lsserverA',
@srvproduct='',
@provider='SQLNCLI',
@datasrc='Server1.abc.com\
ASKER
tigin44: does it matter which db server to run that script? is this link preserved upon a physical reboot of server?
I assume that you will run this code on ServerB ... you can run it vice versa but you should change the linked server and references to the new definitions to run it on ServerA...
ASKER
(1 db is on a dedicated and other on a public shared cloud environment for example).