Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Executing a stored procedure from an insert trigger?

Status
Not open for further replies.

dougcoulter

Programmer
Joined
Mar 16, 2001
Messages
112
Location
US
I am having difficulty executing a stored procedure from an insert trigger (and it appears to be syntax related). Uon an insert into this table, I would like to call a stored procedure requiring 2 parameters that correspond to 2 fields in the trigger table. For example (this is the statement in question):

EXECUTE spFaultDurations Inserted.Field1, Inserted.Field2

The stored procedure works fine when I manually call it. I have not worked with triggers before, so I am not sure if I am referring to the inserted fields correctly. Can anyone help?

Thanks!
 

Declare variables, assign values from the inserted table and pass the variables in the procedure call.

Declare @var1 <data type>, @var2 <data type>

Select @var1=field1, @var2=Field2 From inserted

EXECUTE spFaultDurations @var1, @var2 Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
 
Thanks Terry. I will definitely give it a shot this afternoon.
 
Terry...

Thanks again. With you advice, I was able to get things working!

...Doug
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top