I am trying to set up a DTS package to run every day. What needs to happen is it need to check on table for any updated records with an AGENCY_ID of 6 from the REPORT TALBE against TEMP table. If the LASTUPDATE fields do not match, then a new copy of the record needs to be appended to the TEMP table, not overwriting the old one...to keep a running log. THis is what I have, and it's not working:
INSERT INTO dbo.JCAHO_CROSSWALK
(REPORT_ID, USER_ID, VISN_ID, AGENCY_ID, SURVEY_ID, VA_FACILITY_ID, ASSIGN_FACILITY_NUM, VISIT_DATE, REPORT_DATE,
ACCREDITATION_TIME_PERIOD_ID, ACCREDITATION_ID, GRID_SCORE, SURVEYORS, REPORT_TYPE, LASTUPDATE, DETAILS_EXIST)
SELECT REPORT_ID, USER_ID, VISN_ID, AGENCY_ID, SURVEY_ID, VA_FACILITY_ID, ASSIGN_FACILITY_NUM, VISIT_DATE, REPORT_DATE,
ACCREDITATION_TIME_PERIOD_ID, ACCREDITATION_ID, GRID_SCORE, SURVEYORS, REPORT_TYPE, LASTUPDATE, DETAILS_EXIST
FROM REPORT
WHERE (AGENCY_ID = 6 AND REPORT.LASTUPDATE <> LASTUPDATE) bb
INSERT INTO dbo.JCAHO_CROSSWALK
(REPORT_ID, USER_ID, VISN_ID, AGENCY_ID, SURVEY_ID, VA_FACILITY_ID, ASSIGN_FACILITY_NUM, VISIT_DATE, REPORT_DATE,
ACCREDITATION_TIME_PERIOD_ID, ACCREDITATION_ID, GRID_SCORE, SURVEYORS, REPORT_TYPE, LASTUPDATE, DETAILS_EXIST)
SELECT REPORT_ID, USER_ID, VISN_ID, AGENCY_ID, SURVEY_ID, VA_FACILITY_ID, ASSIGN_FACILITY_NUM, VISIT_DATE, REPORT_DATE,
ACCREDITATION_TIME_PERIOD_ID, ACCREDITATION_ID, GRID_SCORE, SURVEYORS, REPORT_TYPE, LASTUPDATE, DETAILS_EXIST
FROM REPORT
WHERE (AGENCY_ID = 6 AND REPORT.LASTUPDATE <> LASTUPDATE) bb