Hi all -
I am wondering how I would go about updating data from one table to another entirely each night.
Here's what I have so far
CREATE TABLE #tempTable (KEY_ID nchar(10), BOL_NUM nchar(20), DATE_ENTER DATETIME, DATE_RCVD DATETIME, MSTR_VEND_ID nchar(10), PART_NUM nchar(10),
PO_NUM nchar(10), PUR_UOM nchar(10), QTY_RCVD integer, RCVR_NUM nchar(10), SHIP_DATE DATETIME, SHIP_NUM NCHAR(10))
INSERT INTO #tempTable
SELECT * FROM OPENQUERY(CMISERVER, 'SELECT KEY_ID, BOL_NUM, DATE_ENTER, DATE_RCVD, MSTR_VEND_ID, PART_NUM, PO_NUM, PUR_UOM, QTY_RCVD, RCVR_NUM, SHIP_DATE,
SHIP_NUM FROM V_RPS_RCPT_MK')
INSERT INTO T4M.dbo.tbl_RPS_RECEIPTS_MK
SELECT * FROM #tempTable WHERE KEY_ID NOT IN ( SELECT KEY_ID FROM tbl_RPS_RECEIPTS_MK)
RETURN
What I want to do is after the insert statement has found the extra fields that have been added to then do an update to make sure all data is correct in both sources. I'm synchronizing data from a unidata database and a sql database.
I am wondering how I would go about updating data from one table to another entirely each night.
Here's what I have so far
CREATE TABLE #tempTable (KEY_ID nchar(10), BOL_NUM nchar(20), DATE_ENTER DATETIME, DATE_RCVD DATETIME, MSTR_VEND_ID nchar(10), PART_NUM nchar(10),
PO_NUM nchar(10), PUR_UOM nchar(10), QTY_RCVD integer, RCVR_NUM nchar(10), SHIP_DATE DATETIME, SHIP_NUM NCHAR(10))
INSERT INTO #tempTable
SELECT * FROM OPENQUERY(CMISERVER, 'SELECT KEY_ID, BOL_NUM, DATE_ENTER, DATE_RCVD, MSTR_VEND_ID, PART_NUM, PO_NUM, PUR_UOM, QTY_RCVD, RCVR_NUM, SHIP_DATE,
SHIP_NUM FROM V_RPS_RCPT_MK')
INSERT INTO T4M.dbo.tbl_RPS_RECEIPTS_MK
SELECT * FROM #tempTable WHERE KEY_ID NOT IN ( SELECT KEY_ID FROM tbl_RPS_RECEIPTS_MK)
RETURN
What I want to do is after the insert statement has found the extra fields that have been added to then do an update to make sure all data is correct in both sources. I'm synchronizing data from a unidata database and a sql database.