Adding conditional Update if already exists or Insert
Hi, Do you have any idea how I could modify that query to not only do inserts, but to first check if a record exists, and update it and if not then insert.
I've done that with a single row updates like this:
UPDATE tracking
SET search_dt = GETDATE()
WHERE cc_id = #cc_id#
AND zip = '#getCustomer.zip#'
IF @@ROWCOUNT = 0
BEGIN
INSERT INTO tracking
(cc_id, zip, search_dt)
VALUES
(#cc_id#, '#getCustomer.zip#', GETDATE())
END
But I have no idea how to combine the loading from XML part with this type of logic or even if that's possible...
Thanks,
-Roman
|