Re: Easy Trigger "?" question
From: Hari (hari_prasad_k_at_hotmail.com)
Date: 05/26/04
- Next message: Ashish Ruparel [MSFT]: "RE: help with Query building"
- Previous message: Ashish Ruparel [MSFT]: "RE: Comparing COUNTs from a self-join"
- In reply to: steve.beasley: "Easy Trigger "?" question"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 26 May 2004 09:13:42 +0530
Hi,
You can use one of the below
1. Stored Procedures
2. Insert Trigger
You can write a stored procedure
1. First the protecure insert the data in to the tableA, Once the insert is
successful. The same SP can fire 4 inserts to load the other tables
2. Write a Insert Trigger to fire when there is an insert in tablea and load
the other tables.
Sample for insert trigger
-- creation of 3 tables
create table tablea( a int)
go
create table tableb( a int)
go
create table tablec( a int)
go
-- INsert trigger
create trigger ins on tablea for insert
as
insert into tableb select * from inserted
insert into tablec select * from inserted
go
-- insert statement
insert into tablea values(3)
go
select * from tablea
go
select * from tableb
go
select * from tablec
Thanks
Hari
MCDBA
"steve.beasley" <anonymous@discussions.microsoft.com> wrote in message
news:BE0DB5D7-8AE0-4F5D-A9F4-CC37AC2DBA2D@microsoft.com...
> I would like to know the best method (detailed if possible) for
duplicating primary keys. I have a database with 5 tables, (tableA,
tableB...) each with a primary key of JobNumber. If and when someone
inserts a new JobNumber into Table A, I would like the corresponding field
in the other four tables to be populated as well.
- Next message: Ashish Ruparel [MSFT]: "RE: help with Query building"
- Previous message: Ashish Ruparel [MSFT]: "RE: Comparing COUNTs from a self-join"
- In reply to: steve.beasley: "Easy Trigger "?" question"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|