Wednesday 9 October 2013

09. The details of the two employees designated as clerk have been removed from the EmployeeDetails table. Write the SQL statement to reflect these changes made in the EmployeeDetails_Backup table.

Merge EmployeeDetail_Backup
as Target using EmployeeDetail
as Source on (Target.EmployeeID= Source.EmployeeID)
When Matched and
Target.Designation <> Source.Designation
Then Update set Target.Designation= source.Designation
when Not Matched then
Insert Values(Source.EmployeeID,
Source.EmpName,source.designation,
Source.salary,Source.DeptNo)
When Not Matched by Source Then Delete;

No comments:

Post a Comment