View Single Post
  #1 (permalink)  
Old January 16th, 2007, 04:34 AM
AzlanAziz AzlanAziz is offline
Registered User
 
Join Date: Jan 2007
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to AzlanAziz
Default Creating stored procedure with trigger (HOWTO ..)

I have 3 relational tables:

Boat - Boatname,sailNo(PK),
Cook - MemberNo(PK),name,SailNo(FK)
ClubCompetition - CompID(PK),endtime,SailNo(FK)

Boat may or may not have a cook and can enter 1 or more ClubCompetition
how do i create stored procedure with trigger so that i can update
only the tables with user supply input(let say table Boat and ClubCompetition only)
MemberNo is an autogenerateid so whenever i execute the procedure the cook table will be filled with
an ID and SailNo(foreignkey for table Boat)

CREATE PROCEDURE InsSamples
@BoatName varchar(150),
@MemberNo varchar(150),
@name varchar(150),
@endtime datetime
@Whatever
AS
Begin
Set NoCount on
Insert Boat(BoatName)
Values(@Boatname)

Insert into Cook
(MemberNo,name,SailNo)
Values
(@MemberNo,@name,scope_identity())

Insert into ClubCompetition
(CompID,endtime,SailNo)
Values
(@CompID,endtime,scope_identity())

Reply With Quote