Tuesday, June 17, 2025 5:57 PM: Durability: Committed Permanently Saved System Crashes
Tuesday, June 17, 2025 5:57 PM: Durability: Committed Permanently Saved System Crashes
✓ View: A virtual table based on a SELECT query. It does not store data itself.
✓ Can a view be updated? Yes, if it's a simple view on a single table without joins or aggregates.
✓ Difference between View and Table?
▪ View: Virtual, no data storage.
▪ Table: Physical, stores data.
✓ Indexed View: A view that is materialized and stored physically with a unique clustered index to boost
performance.
✓ Transactions:
▪ A transaction is a logical unit of work that must be either fully completed/commit or fully rolled
back.
✓ ACID
▪ Atomicity: Atomicity ensures that either all operations in a transaction are completed
successfully, or none at all. If any part fails, the entire transaction is rolled back.
▪ Consistency: Data should be valid according to all defined rules
▪ Isolation: Isolation ensures that concurrent transactions do not interfere with each other.
▪ Durability: Once a transaction is committed, the changes are permanently saved, even if the
system crashes afterward.
✓ SP:
▪ A Stored Procedure is a precompiled collection of one or more SQL statements that are stored
and executed on the SQL Server.
▪ Can a procedure return a value? (Yes, via RETURN or OUTPUT parameters)
▪ What’s the max number of parameters? (2,100)
Answer Page 1
▪ What’s the max number of parameters? (2,100)
▪ Can you use transactions inside a procedure? (Yes, with BEGIN TRANSACTION, COMMIT,
ROLLBACK)
▪ Can a procedure call itself? (Yes, it supports recursion)
✓ Trigger: A trigger is a special type of stored procedure that automatically executes in response to
specific events on a table or view, such as INSERT, UPDATE, or DELETE.
✓ Types:
▪ DML Triggers
○ After Triggers
○ INSTEAD OF Triggers
▪ DDL Triggers
▪ LOGON Triggers
✓ Can a trigger call a stored procedure? Yes
✓ Can we use transaction in a trigger? Yes
✓ Can a trigger be recursive? Yes
✓ Can a table have multiple triggers for the same event? Yes
✓ How to check existing triggers in SQL Server?
-- List all triggers
SELECT * FROM sys.triggers;
-- Triggers on a specific table
SELECT * FROM sys.triggers WHERE parent_id = OBJECT_ID('TableName');
✓ How do you disable or enable a trigger?
DISABLE TRIGGER TriggerName ON TableName;
ENABLE TRIGGER TriggerName ON TableName;
✓ What is the difference between AFTER and INSTEAD OF triggers?
✓ SP vs Trigger:
SP Trigger
Call manually automatically
Input/Output Parameter ✓ X
Return value ✓ X
✓
Answer Page 2