Thursday, May 1, 2008

SQL Server Triggers

Triggers are stored procedures, which are fired when the changed data underlying the table. They can evaluate the data is added to the table for verification purposes, or may make changes in this or in other areas depending on the value of these data. You can even use them to carry out a separate stored procedure or rollback data modification or the whole transaction.
In earlier versions of SQL Server, triggers were used to maintain referential integrity. In the current version, difficulties and foreign keys are used to perform most of these tasks, but also a matter still to perform more complex tasks than are available built into new tools, such as complex column restrictions assessment tables in other databases, Complex by default, or cascading of several sub-related changes in several tables.
Triggers created in Enterprise Manager, or in Query Analyzer object through a browser. There are also templates for triggers in Query Analyzer (Edit Insert triggers). Triggers can be created using the following syntax:

CREATE TRIGGER trigger name
ON (table ) view
[with encryption]
(((
ON AFTER INSTEAD) ([INSERT] [,] [UPDATE])
[with APPEND ]
[not for replication]
AS
[(if update (column)
[(I I) UPDATE (column)]
[... n]
IF (COLUMNS UPDATED () (bitwise operator) updated bitmask)
( comparison operator) column bitmask [... n]
)]
sql statement [... n]
)
)

There two types of triggers: After instead. After triggers AFTER triggers after the fire changed data, or add, delete or update. If the data is not suitable, as defined in the trigger, changes can be rolled back to where he had the figures were altered. After triggers AFTER triggers can not be placed on the views, and can not be used on more than one table. In addition, the text, ntext, and the image columns can not be mentioned in the show after. AFTER triggers.
After triggers AFTER triggers can be embedded up to 32 levels deep, and can be called recursively, again up to 32 levels. INSTEAD OF triggers make
Instead of checking before modification. However, instead INSTEAD factors can be used on views. They do not allow recursion, and you can only have one Instead of INSTEAD OF trigger at the table. And you can not use instead INSTEAD OF trigger to cascade.
Resources
information on challenges and triggers
This resources is seen around the restrictions and triggers in detail.
Information: Creating triggers
This is a useful resource for understanding the functioning of triggers in detail.

Metro NY / NJ SQL Server Consultants specialize
We normal database software. Call us at the free advice (973) 635 0080 or e-mail us at paladn.com.



Bookmark it: del.icio.usdigg.comreddit.comnetvouz.comgoogle.comyahoo.comtechnorati.comfurl.netbloglines.comsocialdust.comma.gnolia.comnewsvine.comslashdot.orgsimpy.com

No comments: