Saturday 15 June 2013

SQL Server Insert Failed (Not preventing rest of script) -


This is probably a simple question, but I'm doing some inclusion for a company, and some of the "maybe" first If this can be present, it will fail because the primary key value already exists ...

The question is ... the rest will go through updates / inserts?

Is it just a way to overwrite or continue with the rest of the script?

Thank you

If you are working on a set:

  INSERT < Foo & gt; Select & lt; Accessories & gt;   

Then the operation is atom - it will do all this work, or none of it (and this is a good thing). However, if you are inserting a single cursor based single item, the failure to insert will probably not stop the batch. However, it is very slow.

Although you really want to use the merge statement - assuming that you are using SQL Server 2008 or better.

Or you read a WHERE

here: To ensure that you do not attempt to insert rows, Your INSERT statement does not exist () section

No comments:

Post a Comment