Jump to content

Trigger vs Stored procedure


Recommended Posts

I am wanting to write a procedure that will insert new/updated fields into another table

 

Ex: tblStaff and tblUsers

 

Fields in tblUsers needs to be inserted into tblStaff when new records or added or fields are updated. What is the best route to go to accomplish this?

Link to post
Share on other sites

Triggers and stored procedures are used for different things. If you want something to happen when records are added or updated then you use a trigger for that. Your trigger can run a stored procedure if you want it to.

Link to post
Share on other sites

You should probably read up on stored procedures if you don't understand that. The delimiter keyword changes the end-of-statement delimiter. They change it before defining the stored procedure so that the entire create procedure is seen as a single statement, and then they change it back to the default after defining the procedure. The parameter in parentheses defines a variable called countryname that is an input varchar variable.

Link to post
Share on other sites

I have been looking over stored procedures for quite some time now and can't seem to find an example of what I'm wanting to do. I'm wanting to pull certain fields from database A to be inserted into database B and update accordingly. I was first attempting to write one procedure but then was looking at writing a stored procedure in A and then calling the procedure in B and then inserting there...

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...