Site sponsored by: Idera Try Idera’s new SQL admin toolset
SQL Server Performance

  • Home
  • Articles
  • Forums
  • Tips
  • Quiz
  • FAQ's
  • Blogs
  • Software
  • Books
  • About Us
RSS Feeds
Sign in | Join


Article Topics

All Articles
Peformance Tuning
Audit
Business Intelligence
Clustering
Reporting Services
Developer
General DBA
ASP.NET / ADO.NET

SQL Server 2008 - Worth the Wait

SQL Server’s first significant upgrade in three years features a number of envelope-pushing enhancements and improvements. Which will have the greatest impact on SQL administration and development? More...
Latest Articles

Slowly Changing Dimensions in SQL Server 2005
Audit Data Modifications
SQL Server 2008’s Management Data Warehouse
Same Report but Different Methods in SQL Server Reporting Services ...

More     
 
Latest FAQ's

How to Integrate Performance Monitor and SQL Profiler
SSIS Lookups are Case Sensitive
Convert Number to Words in SSRS
After installing SP2 on SQL Server 2005 x64, when trying to ...

More     
   
Latest Software Reviews

SQL Server DBA Dashboard
SwisSQL DBChangeManager
SQLMesh - SQL Server Search Tool
SoftTreeTech SQL Assistant

More     

articles >> developer >> Implementing Triggers in SQL Server 2000 ...

Implementing Triggers in SQL Server 2000

By : Navneeth Diwaker Naik
Aug 31, 2004
Printer friendly

Triggers are special types of Stored Procedures that are defined to execute automatically in place of or after data modifications. They can be executed automatically on the INSERT, DELETE and UPDATE triggering actions.

There are two different types of triggers in Microsoft SQL Server 2000. They are INSTEAD OF triggers and AFTER triggers. These triggers differ from each other in terms of their purpose and when they are fired. In this article we shall discuss each type of trigger.

First of all, let's create a sample database with some tables and insert some sample data in those tables using the script below:

 

Create Database KDMNN

GO

 

USE KDMNN

GO

 

CREATE TABLE [dbo].[User_Details] (

             [UserID] [int] NULL ,

             [FName] [varchar] (50) NOT NULL ,

             [MName] [varchar] (50) NULL ,

             [LName] [varchar] (50) NOT NULL ,

             [Email] [varchar] (50)  NOT NULL

) ON [PRIMARY]

GO

 

CREATE TABLE [dbo].[User_Master] (

             [UserID] [int] IDENTITY (1, 1) NOT NULL ,

             [UserName] [varchar] (50) NULL ,

             [Password] [varchar] (50) NULL

) ON [PRIMARY]

GO

 

ALTER TABLE [dbo].[User_Master] WITH NOCHECK ADD

             CONSTRAINT [PK_User_Master] PRIMARY KEY  CLUSTERED

             (

                           [UserID]

             )  ON [PRIMARY]

GO

 

ALTER TABLE [dbo].[User_Details] ADD

             CONSTRAINT [FK_User_Details_User_Master] FOREIGN KEY

             (

                           [UserID]

             ) REFERENCES [dbo].[User_Master] (

                           [UserID]

             )

GO

 

INSERT INTO USER_MASTER(USERNAME, PASSWORD)

             SELECT 'Navneeth','Navneeth' UNION

             SELECT 'Amol','Amol' UNION

             SELECT 'Anil','Anil' UNION

             SELECT 'Murthy','Murthy'

 

INSERT INTO USER_DETAILS(USERID, FNAME, LNAME, EMAIL)

             SELECT 1,'Navneeth','Naik','navneeth@kdmnn.com' UNION

             SELECT 2,'Amol','Kulkarni','amol@kdmnn.com' UNION

             SELECT 3,'Anil','Bahirat','anil@kdmnn.com' UNION

             SELECT 4,'Murthy','Belluri','murthy@kdmnn.com'


    Next Page>>    








Home | Peformance Articles | Audit Articles | Business Intelligence Articles | Clustering Articles | Developer Articles | Reporting Services Articles | DBA Articles | ASP.NET / ADO.NET Articles | DBA FAQ's | Developer Peformance FAQ's | DBA Peformance FAQ's | Developer FAQ's | Clustering FAQ's | Error Messages | Audit Tool Reviews | Backup Tool Reviews | Coding Tool Reviews | Compare Tool Reviews | Documentation Tool Reviews | Design Tool Reviews | Monitoring Tool Reviews | Log Tool Reviews | Reporting Tool Reviews | Clustering Tool Reviews | Security Tool Reviews | Change Management Tool Reviews | Remote Access Tool Reviews | Book Reviews | Security Tool Reviews | QDPMA Performance Tuning | ADO.NET / ASP.NET | Administration | Analysis/OLAP Services | Application Development | Configuration | Components | ETL | Hardware | High Availability | Hints | Index | Misc | Operating Systems | Performance Tuning | Replication | T-SQL | Views