Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jan 4th, 2013  |  syntax: None  |  size: 0.33 KB  |  views: 21  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. 1.
  2.  MERGE tbl AS target
  3. USING tb2  AS source
  4. ON (target.id = source.id)
  5.  
  6. WHEN MATCHED and source.price >450
  7. then  
  8. UPDATE SET TARGET.price = SOURCE.price,
  9. TARGET.group = SOURCE.group
  10.  
  11.  2.
  12.  update tb1
  13. set
  14. tb1.price=tb2.price,
  15. tb1.group=tb2.group from tb2
  16. left join tb1 on tb1.id =tb2.id
  17. where tb1.id =tb2.id
  18. and tb1.price>450