sql server - Merge Into with no rows -


is there way use instruction:

merge myschema.mytable target using (values ........ ) 

with nothing instead of dots? have there list of (firstvalue, secondvalue,...,lastvalue), 1 each row want merge i'd able write instruction no rows delete part of merge deletes rows.

this because using stored procedure creates merge instruction automatically table starting empty.

of course tried with:

merge myschema.mytable target using (values)  

but not accepted.

thank you.

if you're generating inside query, , outside query matching on predefined id field, following work:

merge tester target using (  select null test1 --generate select null, alias id field ) source on target.test1 = source.test1 when not matched source      delete; 

for particluar case:

merge table1 target using (  values(null) ) source(id) on target.id = source.id when not matched source      delete; 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -