Jump to content

Trigger vs Stored procedure


SqlBeginner

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 comment
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 comment
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 comment
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 comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...