Question : stored proc select and insert where doesn't exist

I have a stored proc that returns a list of IDs from a table - tableA.   If the ID does not exist in a different table - tableB, I need it to insert into tableB.  Once, tableB has matching IDs, I need to rerun the select list from tableA.   How would I write the syntax for this stored proc?

Answer : stored proc select and insert where doesn't exist

It would be somewhat like

-- Script to Insert records

INSERT into tableB (columns_list)
SELECT columns_list
FROM tableA
WHERE not exists (SELECT * FROM tableB where tableA.matching_column = tableB.matching_column)

-- Select records

SELECT *
FROM tableA INNER JOIN tableB ON tableA.matching_column = tableB.matching_column
Random Solutions  
 
programming4us programming4us