Quantcast
Channel: SCN: Message List - SAP Adaptive Server Enterprise (SAP ASE) for Custom Applications
Viewing all articles
Browse latest Browse all 3587

Re: counting inserts/updates when doing a merge

$
0
0

Interesting question.  Here is one way I can think to do it:

 

declare @minserts int, @mupdates int

set @minserts = 0

set @mupdates = 0

merge into myhist as h

    using mytrans as t

      on h.pkey = t.pkey

when matched then update set h.description = t.description, @mupdates = @mupdates + 1

when not matched then insert (pkey,description) values (t.pkey,t.description)

 

select @minserts = @@rowcount - @mupdates

print "UPDATES:  %1!   INSERTS:  %2!",@mupdates,@minserts

 


Viewing all articles
Browse latest Browse all 3587

Trending Articles



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