Thursday, September 24, 2009

70-433 SQL Server - changetable

Setting up a CHANGETABLE


Standard change tracking for developers ...


alter table employee enable change_tracking with (track_columns_updated = ON);


select e.empID, e2.salary FROM (CHANGETABLE(CHANGES employee,NULL))  as e

JOIN dbo.classes e2 on e.empID = e2.empID;


you can also restrict your changetable results, for example, to check the salary changes for empID=42:


CHANGETABLE(VERSION employee, (empID), (42)) as e


No comments: