Comparing UPC codes in MS SQL 2008
I am trying to merge several databases, but I'm not sure how to compare in SQL. The logic is simple. For every row entered, I need to see if the current UPC already exists in the new database. If it does not exist: it should enter the row. If it does exist: it should compare price. If the price is lower, it should enter the row. I suspect that the query would look something like this. It's a rough outline & I'm not even sure if it's the best way to do it. Can anyone start me off in the right direction? loop -- Begin Loop IF (UPC = current_UPC_Variable) -- If the variable being imported is already equal to one Already within the Database THEN WHERE price is better, UPDATE by x criteria '; ELSE enter row; end loop;
September 14th, 2011 11:07am

are you planing to use execute sql task ?? did you get all the source records into a stage table first and then planing to compare with your existing databse and then eventually do update or insert? if so you can just use execute sql task and the above logic is right . else, if the source records are in dataflow you need us transformation components , look up with the existing db.table.column , redirect the match output and then use a oledb command task to write your update statement, redirect the unmtched and you another oledbcommadn to write your insert statement.
Free Windows Admin Tool Kit Click here and download it now
September 14th, 2011 11:29am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics