Quantcast
Channel: Fórum SQL Server Database Engine
Viewing all articles
Browse latest Browse all 15680

custom query between Merge syntax conditions???

$
0
0

Can we write our query inside the merge syntax...

Ex: 

Merge table as T

Using Table as S

on (T.ID=S.ID)

WHEN NOT MATCHED BY TARGET

THEN

{insert query}

-- Here, after inserting records i want to delete them with my CTE as below

[

with CTE_dup as 

  (

{query}

)

delete from CTE_dup where where ID in (1,2,3)

]

WHEN MATCHED 

THEN UPDATE

WHEN NOT MATCHED BY SOURCE 

THEN DELETE


Viewing all articles
Browse latest Browse all 15680

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>