Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- update sc
- set [cnt] = cb.cnt,
- [date] = cb.[date]
- from subscriber_counters_buffer cb
- inner join subscriber_counters sc on sc.subscriber_id = cb.subscriber_id
- and sc.period_type_id = cb.period_type_id
- and sc.channel = cb.Channel
- and sc.counter_type = cb.counter_type
- if(@@ROWCOUNT != (select count(*) from subscriber_counters_buffer))
- begin
- insert into subscriber_counters
- select cb.subscriber_id, cb.period_type_id, cb.channel, cb.[cnt], cb.[date], cb.counter_type
- from subscriber_counters_buffer cb
- where not exists
- ( select 1
- from subscriber_counters sc
- where sc.subscriber_id = cb.subscriber_id
- and sc.period_type_id = cb.period_type_id
- and sc.channel = cb.Channel
- and sc.counter_type = cb.counter_type
- )
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement