Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Try catch for create procedure

Author  Topic 

svjith
Starting Member

5 Posts

Posted - 2009-12-14 : 05:13:42
BEGIN TRY
BEgin tran

alter procedure [dbo].[1s2](
@StartDate datetime)
as
UPDATE [User] SET
StartDate=@StartDate

COMMIT TRAN

print 'Execute'
END TRY

BEGIN CATCH

Rollback TRAN
print 'Catched'
END CATCH;
..................................
the above statement is not running
I am getting the error.

Msg 156, Level 15, State 1, Line 4
Incorrect syntax near the keyword 'procedure'.
Msg 137, Level 15, State 2, Line 8
Must declare the scalar variable "@StartDate".

what can i do..

lionofdezert
Aged Yak Warrior

885 Posts

Posted - 2009-12-14 : 05:42:07
alter procedure must be your first statement, like

alter procedure [dbo].[1s2](
@StartDate datetime)
as

BEGIN TRY
BEgin tran
Go to Top of Page
   

- Advertisement -