SQL_Server_Concepts_Report
SQL_Server_Concepts_Report
Report
Trigger vs Stored Procedure
Trigger:
- Automatically executed when a specific database event occurs (INSERT, UPDATE,
DELETE).
- Cannot be manually called.
- Commonly used for enforcing rules or logging changes automatically.
- Attached directly to a table or view.
Stored Procedure:
- Manually executed using EXEC or EXECUTE.
- Can accept input parameters and return results.
- Used for performing business logic, data manipulation, and complex operations.
- Not automatically linked to data changes.
VARCHAR(50) vs VARCHAR(MAX)
VARCHAR(50):
- Stores up to 50 characters.
- More efficient for performance and storage when size is known.
- Common for short text fields like names or codes.
VARCHAR(MAX):
- Stores up to 2 GB of text data.
- Used for long text fields like articles or documents.
- Slower performance; use only when necessary.