Chapter Summary
- You can use views, stored procedures, and functions to retrieve data. Choose the proper type of object according to a particular situation’s requirements and needs.
- Use a standard view when you want to package a T-SQL query as a unit for security, deployment, and reusability.
- Stored procedures are suitable for scenarios that require the input coming from external values and/or when the expected result might not be a result set but a scalar value.
- User-defined functions (UDFs) enable you to reuse their results in more flexible ways than stored procedures (for instance, in the FROM clause of a SELECT statement, in the Column list section of a SELECT statement, and in a WHERE or HAVING clause of a SELECT statement).
- UDFs cannot be used to perform actions that modify the database state, and they can only declare input parameters.
© Microsoft. All Rights Reserved.