Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. MERGE into dbo.water_quality_data_his AS target
  2. USING dbo.water_quality_data_his_temp AS source
  3. ON (target.id = source.id)
  4. WHEN MATCHED
  5. THEN UPDATE SET
  6. target.[id] = source.[id],
  7. target.[point_id] = source.[point_id],
  8. target.[item_id] = source.[item_id],
  9. target.[item_name] = source.[item_name],
  10. target.[item_unit] = source.[item_unit],
  11. target.[value] = source.[value],
  12. target.[moni_time] = source.[moni_time],
  13. target.[flag] = source.[flag],
  14. target.[lower_limit] = source.[lower_limit],
  15. target.[upper_limit] = source.[upper_limit],
  16. target.[dec] = source.[dec],
  17. target.[update_time] = source.[update_time]
  18. when not matched by target
  19. then insert
  20. values(
  21. source.[id],
  22. source.[point_id],
  23. source.[item_id],
  24. source.[item_name],
  25. source.[item_unit],
  26. source.[value],
  27. source.[moni_time],
  28. source.[flag],
  29. source.[lower_limit],
  30. source.[upper_limit],
  31. source.[dec],
  32. source.[update_time]
  33. );
  34. --when not matched by source
  35. -- then delete
  36. --OUTPUT $action, Inserted.*, Deleted.*;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement