0

I have 2 SQL Servers. ServerA and ServerB

They both have a table called "OrderRequest"

ServerA is "in house" and ServerB is in our datacenter.

ServerA has a linked server - ServerB On ServerB there is a linked server back to ServerA

I need to remove the latter linked server, as the firewall that allows ServerB to "see" ServerA is changing, and won't allow this any more.

We have a SSIS package that copies data from our datacenter (ServerB) to our in-house Server (ServerA)

At the moment, the SQL statement is along the lines of:

SELECT *
FROM ServerB.OrderRequest
WHERE
OrderID NOT In (SELECT OrderID FROM ServerA.OrderRequest)

As you can see, this will require ServerB to be able to “see” ServerA

What I want to do is something like:

SELECT *
FROM ServerB.OrderRequest
WHERE
Transferred = 0

This is easy enough to do. However, in my SSIS I have a Union (as I have more than one WebDB) After that, they are inserted into ServerA.

What I’d need to do, is set Transferred to true, on successful insert. How would I go about doing this?

Alex
  • 37,502
  • 51
  • 204
  • 332

1 Answers1

1

There are obviously many ways to do this, but it depends on a few factors (for instance, are you inserting more records into ServerB as you are doing the transfer?)

  • Do a multicast to a foreach container with an OLE DB command inside. Call update on each record on ServerB.
  • Start a transaction before you select. After the select is complete, update all rows to transferred (if you want even more atomicity, select into a temp table to ensure you're updating correctly). Once complete: commit. Fail: rollback.
  • Simply run a SQL Command on completion: UPDATE ServerB.OrderRequest SET Transferred = 1 WHERE Transferred = 0
Stefan Mai
  • 23,367
  • 6
  • 55
  • 61
  • thanks, after some more googling, i think the foreach container is the way forward... any idea how to do it? I've added another Q on this subject - http://stackoverflow.com/questions/4614518/ssis-using-a-foreach-loop-container-to-update-records-after-transfer – Alex Jan 07 '11 at 12:43