Stored Procedure Coding Guidelines and Limitations
Stored procedures should be treated just like reusable application code. Follow these suggested guidelines to ensure your stored procedures are solid and robust:
Check all parameters for validity and return an error message if a problem exists.
Be sure that the parameter datatypes match the column datatypes they are compared against to avoid datatype mismatches and poor query optimization.
Check the @@error system function after each SQL statement, especially insert, update, and delete, to verify that the statements executed successfully. Return a status code other than 0 if a failure occurs.
Be sure to comment your code so that when you or others have to maintain it, the code is self-documenting. ...
Get Microsoft® SQL Server™ 2000 Unleashed, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.