Hi there,
I have a DTS package that I am running to import data to a database, the flow it follows is as such:
1. Import the data to a staging area
2. Remove any invalid records (ones with invalid data) and move to another table for analysis
3. Remove any records that may already be in the table and move into another table for analysis
4. Import everything that is left in teh staging area to the destination table
I seem to be having a problem with the SQL code that I am using in stage 3 - I have had to use a basic sql string for this becuase the system is handled by a few people, and not everyone is good at sql (im an average user myself), this is then used to change the DTS Pump. Basically, the code I am using is:
SELECT * FROM Import where Brochure_Code IN(Select Brochure_Code from IDF) AND Market_ID in (Select Market_ID from IDF) AND Warehouse_ID in (Select Warehouse_ID from IDF) AND Year in (Select Year from IDF) AND Month in (Select Month from IDF) Order by Market_ID
(messy, I know). It 'seems' to work, and I use the term loosely, for some reason, it will remove some records that are already there, but it also seems to be removing records that aren't actually there (in the destination table [IDF]) and moves them too!!! I am perplexed as to why it is doing this.
Can anyone offer me a bit of SQL code that can be used to compare two records in two different tables to see if certain fields are the same - in this case, the fields are:
Brochure_code
Warehouse_ID
Year
Month
Market_ID
(these 5 fields make up the primary key and CANNOT be changed - too many other things rest upon them)
Feel free to rip apart the code, or ask more questions. Any and all help will be appreciated.
ConBran
I have a DTS package that I am running to import data to a database, the flow it follows is as such:
1. Import the data to a staging area
2. Remove any invalid records (ones with invalid data) and move to another table for analysis
3. Remove any records that may already be in the table and move into another table for analysis
4. Import everything that is left in teh staging area to the destination table
I seem to be having a problem with the SQL code that I am using in stage 3 - I have had to use a basic sql string for this becuase the system is handled by a few people, and not everyone is good at sql (im an average user myself), this is then used to change the DTS Pump. Basically, the code I am using is:
SELECT * FROM Import where Brochure_Code IN(Select Brochure_Code from IDF) AND Market_ID in (Select Market_ID from IDF) AND Warehouse_ID in (Select Warehouse_ID from IDF) AND Year in (Select Year from IDF) AND Month in (Select Month from IDF) Order by Market_ID
(messy, I know). It 'seems' to work, and I use the term loosely, for some reason, it will remove some records that are already there, but it also seems to be removing records that aren't actually there (in the destination table [IDF]) and moves them too!!! I am perplexed as to why it is doing this.
Can anyone offer me a bit of SQL code that can be used to compare two records in two different tables to see if certain fields are the same - in this case, the fields are:
Brochure_code
Warehouse_ID
Year
Month
Market_ID
(these 5 fields make up the primary key and CANNOT be changed - too many other things rest upon them)
Feel free to rip apart the code, or ask more questions. Any and all help will be appreciated.
ConBran