Breaking News
Loading...
21/08/2013

Using Joins in Update and Delete statements

This is SQL technical I usually use in my tasks.

Sometimes you need to update or delete records based on matching records in another table. You may use sub-query for this but there is a better approach by using Joins in your update and delete statements.

Following is an example of how to implement it in your code.

Update d

Set d.Department = Deptt.SEGMENT4_DESCRIPTION

From dimDepartment d

Inner Join Deptt

On d.DepartmentKey = Deptt.SEGMENT4_CODE;

 

Delete d

From dimDepartment d

Inner Join Deptt

On d.DepartmentKey = Deptt.SEGMENT4_CODE;
Source: http://bloggerzspot.com/using-joins-in-update-and-delete-statements/

0 comments:

Post a Comment

 
Toggle Footer