I have a table that holds data from a linked server. It is updated daily.
When I update it, I need to add any new leases as well as update any leases where the effective date or expiration date has changed. Is there any way to do this without checking each lease individually? I'm pretty sure that I can add the new leases with a WHERE NOT EXISTS clause like
Is the syntax correct? Can I do something similar with an UPDATE statement to capture updated dates?
Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook
Code:
[u]tLease[/u]
leaseNum
effDate
expDate
Code:
INSERT tLease
SELECT leaseNum, effDate, expDate
FROM OPENQUERY(linkCN,'SELECT leaseNum, effDate, expDate FROM otherTable')
WHERE NOT EXISTS (SELECT leaseNum FROM tLease)
Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook