T-SQL Mergeのサンプル
MERGE INTO test_table AS A
USING (SELECT 10 AS no,'太郎さん' AS name, 30 AS age ) AS B
ON
(
A.no = B.no
)
WHEN MATCHED THEN
UPDATE SET
name = B.name
,age = B.age
WHEN NOT MATCHED THEN
INSERT (no,name,age)
VALUES
(
B.no
,B.name
,B.age
)
0 件のコメント:
コメントを投稿