TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Amudhan Kuppan
NA
378
29.9k
Merge Statement do not use ID
Mar 23 2018 1:16 AM
hi
anyone help me
use master
Go
MERGE INTO dbo.student AS S
USING dbo.Student AS D
ON S.id = D.id
WHEN MATCHED AND (S.name != D.name OR S.Address!= D.Address) THEN
UPDATE SET S.name = D.name,S.Address = D.Address
WHEN NOT MATCHED BY TARGET THEN
INSERT VALUES (D.id, D.name, D.Address)
WHEN NOT MATCHED BY SOURCE THEN
DELETE OUTPUT D.id,$action,inserted.id, deleted.id;
this is my query for merge statement iam use same table for a source and destination
my requirement is:
please check with name and insert and update do not use id. , please correct the script and send me back
Reply
Answers (
1
)
Merge Statement
Stored Procedure