Advertisement
Guest User

Untitled

a guest
Jan 15th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.41 KB | None | 0 0
  1. merge brief_log as Target
  2.   using (select id from brief_log
  3.         where login = 'john'
  4.         and day(first_check_date) = day(getdate())
  5.         and month(first_check_date) = month(getdate())
  6.         and year(first_check_date) = year(getdate())) as Source
  7.   on Target.id = Source.id
  8.   when matched then
  9.   update set
  10.     count += 1
  11.   when not matched by target then
  12.   insert values
  13.     ('john', getdate(), null, null, 1, null);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement