Idempotent (run twice safe) sql statements

if (select count(*) from neatoSchema.YourTable where SomeColumnYouCanCheckDataOn = 2018)> 0
begin
print 'That row is already inserted'
end
else
begin
INSERT into neatoSchema.[ConferenceDate]
(... your data ...)
end

You can also interrogate information_schema.tables or information_schema.columns if you are doing a change to a table to ensure that doesn’t run twice!

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.