When we delete records the Deleted Table will be used, and the deleted records are stored in the Deleted Table.

Query to demonstrate the Deleted Table used in a Delete Statement:

DROPTABLE #Student

CREATETABLE #Student

(

IStudentID intidentity (1, 1)

,vchStudentFirstName varchar(100)

, vchStudentLastName varchar (100)

, vchDepartment varchar (50)

)

INSERTINTO #Student values ('FirstName1','LastName1','BCA')

INSERTINTO #Student values ('FirstName2','LastName2','MCA')

INSERTINTO #Student values ('FirstName3','LastName3','BCS')

INSERTINTO #Student values ('FirstName4','LastName4','BA')

DELETEFROM #Student OUTPUT deleted.*WHERE iStudentID=33. Update

When we update records then both the Inserted and Deleted Tables are used; first it will delete the record and then insert and store these results in the Inserted & Deleted Tables; see:Query to demo Inserted & Deleted Table used in Update Statement,