Wednesday, February 12, 2014

Delete a table data using JOINS in SQL Server

Here is how we can delete using JOINS. I have used inner join here.

DELETE
Table1
FROM
Table1 INNER JOIN Table2
ON Table1.Field2 = Table2.Field2
WHERE -- YOUR WHERE CONDITIONS
Table2.Field3 IS NOT NULL


Hope this helps

Update a table using JOINS in SQL Server

Here is how we can update a table using JOINS in SQL SERVER.

UPDATE
Table1
SET
Table1.Field1 = Table2.Field1
FROM
Table1
INNER JOIN Table2 ON Table1.Field2 = Table2.Field2
WHERE -- YOUR WHERE CONDITIONS
Table2.Field3 IS NOT NULL


Hope this helps