Friday 12 April 2013

What is difference between stored procedure and Trigger in SqlServer

Stored procedure:

  • Stored procedures are executed explicitly.
  • Procedure can be created without a table.
  • procedure accepts parameters.
  • procedure can return values.
  • procedure can be called from front-end Application.
              syntax :   
                       create|alter procedure<name>[parameters] (here parameters are optional)
                        as
                         begin
                         statements
                           end
Triggers:


  • Triggers are executed implicitly.
  • Trigger can't be created without a table.
  • Trigger can't return values.
  • Trigger can't be called from front-end Application
      Syntax : 
                      create |alter trigger<name>
                       on <tablename>
                        after|instead of insert,update,delete 
                       as
                       begin
                        .......statements.........
                       end

No comments:

Post a Comment