SQL Server Insert if not exists

instead of below Code replace with Updated : (thanks to @Marc Durdin for pointing) Note that under high load, this will still sometimes fail, because a second connection can pass the IF NOT EXISTS test before the first connection executes the INSERT, i.e. a race condition. See stackoverflow.com/a/3791506/1836776 for a good answer on why even wrapping in a … Read more