I am trying to iterate thru an existing table using CURSOR FOR and checking if the current row being processed has a similar row in another newly created table. If there isnt a similar row in the new table, then i would want to insert that row which is being processed into the new table. The following is a sample of my code.
transaction_unique is the name of my new table.
I am getting syntax error with my CASE statement. Could someone please point out the correct syntax? thks
WHILE @@FETCH_STATUS = 0
SET @count = @count + 1
--check if the current transaction exist
WHEN @member_deduct > 0 THEN
IF NOT EXISTS (SELECT TOP 1 * FROM transaction_unique WHERE product_code = @product_code member_deduct > 0) THEN
INSERT INTO transaction_unique VALUES(@product_code,'member_deduct')
FETCH currentRow INTO @product_code,@member_deduct