I am doing an update on a table and need to get both the value of a field before the update and the value of the field after the update. I am getting the value before the update from the deleted table and the value after the update from the inserted table (see below). Is this the correct way to do this ?
insert into [log].[userPoints]
(accountId,oldPoints,newPoints)
SELECT del.accountId, del.points, i.points
FROM [user].[Points] AS p
INNER JOIN deleted AS del ON del.accountId = p.accountId
inner join inserted as i on i.accountId = p.accountId
Yes, entirely correct. You can access both tables in the same SQL statement, and your joins look good.