Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MERGE into dbo.water_quality_data_his AS target
- USING dbo.water_quality_data_his_temp AS source
- ON (target.id = source.id)
- WHEN MATCHED
- THEN UPDATE SET
- target.[id] = source.[id],
- target.[point_id] = source.[point_id],
- target.[item_id] = source.[item_id],
- target.[item_name] = source.[item_name],
- target.[item_unit] = source.[item_unit],
- target.[value] = source.[value],
- target.[moni_time] = source.[moni_time],
- target.[flag] = source.[flag],
- target.[lower_limit] = source.[lower_limit],
- target.[upper_limit] = source.[upper_limit],
- target.[dec] = source.[dec],
- target.[update_time] = source.[update_time]
- when not matched by target
- then insert
- values(
- source.[id],
- source.[point_id],
- source.[item_id],
- source.[item_name],
- source.[item_unit],
- source.[value],
- source.[moni_time],
- source.[flag],
- source.[lower_limit],
- source.[upper_limit],
- source.[dec],
- source.[update_time]
- );
- --when not matched by source
- -- then delete
- --OUTPUT $action, Inserted.*, Deleted.*;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement