Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Sql server 2008 and following
- MERGE INTO Table
- USING (
- SELECT id, col1, col2
- FROM other_table
- WHERE sql = 'cool'
- ) AS source
- ON Table.id = source.id
- WHEN MATCHED THEN
- UPDATE
- SET col1 = source.col1,
- col2 = source.col2;
- --general
- UPDATE
- Table
- SET
- Table.col1 = other_table.col1,
- Table.col2 = other_table.col2
- FROM
- Table
- INNER JOIN
- other_table
- ON
- Table.id = other_table.id
- INSERT INTO table1 ( column1 )
- SELECT col1
- FROM table2
Advertisement
Add Comment
Please, Sign In to add comment