Bạn không thể thả một chức năng người dùng định nghĩa nếu nó được sử dụng trong một định nghĩa hạn chế. Nếu bạn thả một chức năng và nó là UserDefined sử dụng trong các chức năng khác, xem, gây nên, hoặc thủ tục lưu trữ, chức năng Những sẽ sản xuất một lỗi trên thực hiện tiếp theo. | Microsoft SQL Server 2000 Programming by Example CREATE TRIGGER tr1_Customers ON Customers AFTER UPDATE AS -- Your code here PRINT This is the tr1 trigger GO CREATE TRIGGER tr2_Customers ON Customers AFTER UPDATE AS -- Your code here PRINT This is the tr2 trigger GO CREATE TRIGGER tr3_Customers ON Customers AFTER UPDATE AS -- Your code here PRINT This is the tr3 trigger GO -- Test the order of execution -- By using a MOCK operation UPDATE Customers SET ContactName ContactName GO -- Specify the tr3 trigger as first trigger to execute EXEC sp_settriggerorder tr3_Customers FIRST UPDATE -- Specify the tr2 trigger as last trigger to execute EXEC sp_settriggerorder tr2_Customers LAST UPDATE -- Specify the tr1 trigger as any order to execute EXEC sp_settriggerorder tr1_Customers NONE UPDATE GO -- Test the order of execution -- By using a MOCK operation PRINT CHAR 10 After reordering CHAR 10 UPDATE Customers SET ContactName ContactName Go 340 Chapter 9. Implementing Complex Processing Logic Programming Triggers 0 UTPUT This is the This is the This is the tri trigger tr2 trigger tr3 trigger After reordering This is the This is the This is the tr3 trigger tri trigger tr2 trigger Caution Remember that INSTEAD OF triggers are always executed before the data is modified. Therefore they execute before any of the AFTER triggers. Checking for Updates on Specific Columns To check inside a trigger if a column has been updated you can use the IF UPDATE clause. This clause evaluates to TRUE if the column has been updated. To test for changes in multiple columns in a single statement use the COLUMNS_UPDATED function. This function returns a bitmap with the update status of every column in the base table. In other words COLUMNS_UPDATED returns a sequence of bits one bit for every column and the bit is 1 if the column has been updated or otherwise it is 0. Listing shows an example of these two functions. Listing Inside a Trigger You Can Check Which Columns Have Been Updated .