Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 High Availability (2005)
 Creating Delete Trigger

Author  Topic 

boboy_ponce
Starting Member

2 Posts

Posted - 2006-12-18 : 02:58:52

Hi All,
Im new to MS SQL2000, i have two tables, employee as my masterfile and emp_data as my second tables. I need to create trigger so everytime i delete employees from my masterfile, automatically my delete trigger will fire and delete records from my secondary tables of the same employee id.
Your help is highly appreciated.

Regards.

Boboy Ponce

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-12-18 : 03:10:40
Another way is CASCADE DELETE option, provided you have foreign key relationship between the two tables (and it will be more simpler and faster way!)

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

madhuotp
Yak Posting Veteran

78 Posts

Posted - 2006-12-18 : 03:12:43
There are two ways.
(a) Make the Employee -->Emp_data relation as ON Delete Cascade
(b) Create a delete trigger

Refer both in BOL.

Madhu


Go to Top of Page

boboy_ponce
Starting Member

2 Posts

Posted - 2006-12-18 : 03:24:24
quote:
Originally posted by madhuotp

There are two ways.
(a) Make the Employee -->Emp_data relation as ON Delete Cascade
(b) Create a delete trigger

Refer both in BOL.

Madhu


Thanks for your reply.
But what is BOL? and where do i get it?

Boboy


Go to Top of Page

madhuotp
Yak Posting Veteran

78 Posts

Posted - 2006-12-18 : 04:08:26
BOL is Books online. SQL Server Bible/Encyclopedia.WHen u install SQL Server, it must have installed. if not there u can download from

http://msdn2.microsoft.com/en-us/library/ms166018.aspx

Madhu
Go to Top of Page
   

- Advertisement -