stored procedure question  
Author Message
Computers





PostPosted: Sat Feb 05 19:28:13 CST 2005 Top

SQL Server >> stored procedure question

When running a stored procedure definition script how would you guarantee the
definition could be ''rolled back'' in the event of problems?

SQL Server247  
 
 
Dan





PostPosted: Sat Feb 05 19:28:13 CST 2005 Top

SQL Server >> stored procedure question You can enclose DDL in a transaction:

CREATE PROC TestProc AS
PRINT 'this proc is good'
GO

BEGIN TRAN

IF OBJECT_ID('TestProc', 'P') IS NOT NULL
DROP PROCEDURE TestProc
GO

CREATE PROC TestProc AS
xxxPRINT 'this proc is bad'
GO


GO


--
Hope this helps.

Dan Guzman
SQL Server MVP



> When running a stored procedure definition script how would you guarantee
> the
> definition could be ''rolled back'' in the event of problems?