Stored procedure standards | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Stored procedure standards

Hi, I am designing my standard for writing SP.Please provide me your inputs
CREATE PROCEDURE STANDARD
<Input/Output Parameter>
AS SET NOCOUNT ON BEGIN BEGIN TRANSACTION /***DECLARE SECTION***/ /***DEFAULT VALUE SECTION***/ /****SQL QUERY******/ /*****Error Handling code***/ SET @[email protected]@Error IF @ErrorMsgID <> 0
BEGIN
SELECT @ErrorMsg = ‘Error occurred in Stored Procedure ‘ + Object_Name(@@PROCID) +’ while delete’
RAISERROR(@ErrorMsg,16/*severity*/,1/*state*/)
ROLLBACK TRANSACTION
RETURN (-1)
END
COMMIT TRANSACTION END
SET NOCOUNT OFF
RETURN (0) GO Thanks and Regards Ravi K
I always believe there are no global standards. You should define your own standards to suit to your business environment. Better to have a comment section at the top of the SP. with information like Last modified date/Author etc. where you have modification history In additon, you need to define your coding standard as well. —————————————-
Cast your vote
http://www.geocities.com/dineshasanka/sqlserver05.html http://spaces.msn.com/members/dineshasanka

]]>