5052 EXAM Flashcards
What are the 5 advantages of stored procedures?
- Reusable and Consistent
- Security and Control
- Modular
- Speed
- Network
What are 3 disadvantages of stored procedures?
- Server load
- Single Query Plan
- Not portable
What symbol is used to denote a variable or parameter?
@
What keyword is used to call a stored procedure?
EXECUTE
How do you suppress row count information in a stored procedure?
SET NOCOUNT ON
Is it possible to have multiple outputs in a stored procedure?
Yes
What is a scalar function?
A function that returns a single value
What is the rule with brackets around the parameter list regarding procedures and functions?
Stored Procedures = Optional
Functions = Required
How do you specify the return in a function?
- RETURNS (DataType) after the parameter list
- RETURN (variable) at end of function body
Which can be used as an expression, stored procedure or function?
Function
What does ACID stand for?
Atomicity
Consistency
Isolation
Durability
What does atomicity mean?
Entire transaction either succeeds or fails
What does a consistent transaction ensure?
The system will return to the state it was in before the transaction
Which ACID principle(s) apply to transactions still executing?
Isolation
Which ACID principle(s) apply to completed transactions?
Atomicity, Consistency, and Durability
How do you start a transaction?
BEGIN TRANSACTION
How do you specify to reverse a transaction?
ROLLBACK TRANSACTION
How do you specify to save the changes made by a transaction?
COMMIT TRANSACTION
What are 2 types of locks?
- Exclusive Lock
- Shared Lock
When does the system use an exclusive lock?
INSERT, UPDATE, DELETE
When does the system use a shared lock?
Read functions, like SELECT
What are 3 ways to prevent deadlocks?
- Control the flow (stored procedures)
- Keep transactions small
- Consolidate code
What is the rule for default values for stored procedure parameters?
Must be constants or NULL
What does SCOPE_IDENTITY() return?
Last Identity value created in scope
When specifying parameters by name in an execute statement, what side of the ‘=’ is the parameter?
Left