You can do the following1) Capture all records of David(that needs to be updated) by usingSELECT CaseIDFROM CasePermissions aINNER JOIN Staff b ON a.StaffId = b.StaffIDWHERE b.FirstName = 'David' AND b.LastName = 'Whatever_it_is'
2) You can directly update these record's staff id to JOHN's staffid. You won't have a history if you do. you can do that as below.UPDATE aSET a.StaffID = (SELECT StaffID FROM Staff WHERE FirstName = 'John' AND LastName = 'Whatever_it_is')FROM CasePermissions aINNER JOIN Staff b ON a.StaffId = b.StaffIDWHERE b.FirstName = 'David' AND b.LastName = 'Whatever_it_is'
or3) If you want to maintain a history(which I don't see with any sort of dates being handled in the CasePermissions Table)INSERT INTO CasePermissions(StaffID, CaseId)SELECT (SELECT StaffID FROM Staff WHERE FirstName = 'John' AND LastName = 'Whatever_it_is'), a.CaseIDFROM CasePermissions aINNER JOIN Staff b ON a.StaffId = b.StaffIDWHERE b.FirstName = 'David' AND b.LastName = 'Whatever_it_is'
I think you might be using 1 and 2 in your case.. Remember 1 is just for illustration purpose..Visit www.sqlsaga.com for more t-sql code snippets and BI related how to articles.