D
D
Dmitry Petrov2017-06-19 14:58:56
Transact SQL
Dmitry Petrov, 2017-06-19 14:58:56

MSSQL, is there a normal BULK UPSERT?

I switch to ms sql with mysql and suffer wildly from the INSERT ... ON DUPLICATE KEY UPDATE construct in MySQL. This is an awesomely convenient design - you specify the complete instruction for inserting records into the database and separately the fields that need to be updated if the record falls under a unique existing index in the table.
Why MSSQL does not comply with ANSI-92 standards is a separate issue. But the MERGE construct is simply terrible when you need to insert-update thousands of rows and write it - one torment.
Maybe there are some libraries for C# or some tricky implementations of bulk upsert for ms sql itself via code generation and EXEC command?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
n-fom, 2017-06-19
@n-fom

https://docs.microsoft.com/en-us/sql/t-sql/stateme...

D
d-stream, 2017-06-19
@d-stream

In my opinion, the most readable and quite operational is to separate insert and update, which is actually merge from another profile. At least for now, about insert or update - ms is silent like a fish on ice...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question