p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   SQL Language (http://p2p.wrox.com/forumdisplay.php?f=100)
-   -   Creating stored procedure with trigger (HOWTO ..) (http://p2p.wrox.com/showthread.php?t=52751)

AzlanAziz January 16th, 2007 04:34 AM

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())



All times are GMT -4. The time now is 12:41 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.