awesomeindex.com awesomeindex.com
   Main :> About Us :> Security & Privacy :> ToS :> Add Your Link :> Add Article
Search:   
Get Free Links
 
 

Culture & Art

 

Home Family & Garden

 

Online Shopping

 

People & Society

 

Automobile & Automotive

 

News & Media

 

Jobs & Careers

 

Computers & Networking

 

Drink & Food

 

Science & Space

 

Academics & Education

 

Policies & Law

 

Finance & Banking

 

Companies & Business

 

Children

 

Property & Estate

 

Hotels & Travel

 

Relationship & Lifestyle

 

Self Enhancement

 

Recreation

 

Online & Indoor Games

 

Adventure & Sports

 

Medical Care

 

Health & Hygiene

 

Main › Computers & Networking › Computer Software
 

SQL Server Triggers

 

Author: Kemp Chris

Triggers are stored procedures which are fired when data is modified in an underlying table. They can evaluate data being added to a table for validation purposes, or can make changes in that or other fields depending on the value of that data. You can use them even to execute a separate stored procedure, or to roll back a data modification or an entire transaction.

In earlier versions of SQL Server, triggers were used to maintain referential integrity. In current versions, constraints and foreign keys are used to accomplish much of those tasks, but triggers are still used to accomplish more complex tasks than that are available to the built in newer tools, such as complex column constraints, evaluation of tables in other databases, complicated defaults, or cascading routines involving multiple changes in multiple tables.

Triggers are created in the Enterprise Manager, or in the Query Analyzer through the object browser. There are also templates for triggers in the Query Analyzer (Edit|Insert Trigger). Triggers can be created with the following syntax:

CREATE TRIGGER trigger_name
ON { table | view }
[ WITH ENCRYPTION ]
{

{ { FOR | AFTER | INSTEAD OF } { [ INSERT ] [ , ] [ UPDATE ] }

[ WITH APPEND ]

[ NOT FOR REPLICATION ]

AS

[ { IF UPDATE ( column )

[ { AND | OR } UPDATE ( column ) ]

[ ... n ]

| IF ( COLUMNS_UPDATED ( ) { bitwise_operator } updated_bitmask )

{ comparison_operator } column_bitmask [ ... n ]

} ]

sql_statement [ ... n ]

} }

There are two types of triggers: AFTER and INSTEAD OF. After triggers AFTER TRIGGERS fire after the data is changed, either by insert, delete, or update. If the data is inappropriate, as defined in the trigger, the modification can be rolled back to where it was before the data was modified. After triggers AFTER TRIGGERS cannot be placed on views, and cannot be used on more than one table. Also, the text, ntext, and image columns cannot be referenced in an after trigger. AFTER TRIGGERS.

After triggers AFTER TRIGGERS can be nested to 32 levels deep, and can be called recursively, again to 32 levels.

Instead of INSTEAD OF triggers make the validation before the modification. However, Instead of INSTEAD OF triggers CAN can be used on views. They do not allow recursion, and you can only have one Instead of INSTEAD OF trigger per table. And you cannot use an Instead of INSTEAD OF trigger with a cascade.

Resources

" Information on Constraints and Triggers

This resource discusses about constraints and triggers in detail.

" Information: Create Trigger

This resource is useful in understanding the workings of triggers in detail. Metro NY / NJ SQL Server Consultants We specialize is custom database software. Call us for a free consultation (973) 635 0080 or email us at paladn.com

Author Bio:
Kemp Chris is a noted author. Kemp likes to create articles about this area.
You can also reach this article by using: free software, free software downloads, cheap computer software, discount software
 
 
 

Related Articles

 
New Website Marketing Made Easy
 
Making the Most of Low Cost E-zine Ads
 
Your Autoresponder The Key to Seven Profit Centers
 
DXInOne - Issue #1 - Why Are Our Funds Locked In The DXSystem?
 
Cisco CCNA Certification: An Illustrated Guide To Ethernet CSMA/CD
 
Thermal Plants
 
How to Reach the Online Market
 
How To Drive Highly Targeted Traffic To Your Site For Free
 
Hard Drive Data Recovery Services
 
Five Easy Ways to Advertise and Promote Your Website
 
 
 
 

A free virus scanner

Your choice of virus scanners and recommendations on the best of the available free ones. (25/06 ... - Josh Johnson
 

Grow your Business with Emarketplace - Part III

After years of hard work, finally your business started to pick up. You are selling more products th ... - Nowshade Kabir
 

XCPUScalar - Treo 700 Software Review

Review of Treo 700 software that speeds up the device and saves battery life. - Steve Bralovich
 
 

Leveraging Website Exit Strategies to Maximize Profit

Tired of tweaking your website in an effort to get more sales? A clever set of exit strategies can r ... - Matt Bacak
 

5 Ways to Market Your Business For Free - Part I

If you're tired of the high cost of marketing online, then try these free techniques. Not only are t ... - Jinger Jarrett
 

Working Together: Your Music, Movies, Photos on Your iPod, Cell Phone & PDA

Movie and television studios and music labels continue to fight for Digital Rights Management (DRM) ... - Mike Valentine
 

How's Your Sense of Style?

No, I'm not referring to your wardrobe here, but to to cascading style sheets, also known as CSS. De ... - Merle Stinnett
 

Risk of Deafness With the iPod!

Risk of deafness with ipods! Today's kids risk the chance of going deaf in their 40's if they play t ... - Brian Lupichuk
 
 
Main :> Security & Privacy :> ToS
© 2006-2008 www.awesomeindex.com All Rights Reserved Worldwide.