Insert into if not exists
Posted on 2011-03-25
I need to insert records into a table that may or may not have a record with this attributeID. If they do already have a record I want them left alone. If they do not have a record I want to add the record with this attributeID and value specified for every row in another table. I believe I have the insert statement correct, but I am not sure how to exclude the records I want left alone. Please advise.
Insert into CustomProgram (attributeID, ProgramID, value)
select '310', p.program, '650'
from Program p