Week 11 Flashcards
A stored procedure has to be executed by a ________, while a trigger is executed by the _______ as the result of an event.
user, system
Events that cause triggers to be activated include data ________, updates and ________.
Events that cause triggers to be activated include data inserts, updates and deletes.
One drawback to using ________ instead of ___________ is that they cannot accept parameters.
triggers, stored procedures
Stored procedure are for _______ actions or ________ actions
repetitive, complex
Triggers are enforcing business rules or _________.
protection
After creating a stored procedure what is the next step?
Parameters can be passed into the procedure
using @
SQL Server has many built-in stored procedures, called _______ _________ ____________
System Stored Procedures
Store procedure Usage Examples:
EXEC sp_tables
EXEC sp_tables @table_name = ‘Employee’
EXEC sp_tables @table_owner = ‘HumanResources’
How to you create a stored procedure?
starts with EXEC with
prefix sp_(tablename)
add parameters with @(tablename)
How do store procedure help the security of your database?
execute commands without permission in a controlled manner
•Execute As•Reduce/ eliminate SQL injection attacks
•Procedure can be encrypted to prevent copying and modifying
•Table/columns, etc are hidden from caller
What are some benefits of stored procedures?
Speed
Easier maintenance
Reduced network traffic
security
What commands in T-SQL are used to update a stored procedure and create a new one
UPDATE PROCEDURE
CREATE PROCEDURE
What are the two types of triggers?•
Data Manipulation Language (DML)
Data Definition Language (DDL)