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 2000 Forums
 SQL Server Development (2000)
 Can i rewrite this in SQL 2000?

Author  Topic 

prodigy2006
Yak Posting Veteran

66 Posts

Posted - 2008-11-14 : 11:51:34
I've a code which is written in SQL 2005 i.e. using TRY\CATCH for error handling. It basically runs DBCC CheckDB with no repair for databases. I need to develop a code in SQL 2000 which does the error handling but which is SQL 2000 compatible.

I would appreciate if someone could suggest me something in rewriting the code in SQL 2000.
Below is part of the code if you want to have a look at.

BEGIN TRY

------This will update DBA.DBA_MaintHistHeader for a successful complete maintenance procedure

UPDATE DBA.DBA_MaintHistHeader SET StatusID = 1, EndDateTime = GETDATE()
WHERE MaintHistHeaderID = @MaintHistHeaderID ;


END TRY
BEGIN CATCH

SET @ExitMessage = N'Database Maintenance Failure TO UPDATE MaintHistHeader Records with Status of Complete: @MaintHistHeaderID = ' + CONVERT(nvarchar(40),@MaintHistHeaderID) + '';
GOTO Failure;

END CATCH

RETURN;



Thanks........

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-14 : 11:53:53
try this

UPDATE DBA.DBA_MaintHistHeader SET StatusID = 1, EndDateTime = GETDATE()
WHERE MaintHistHeaderID = @MaintHistHeaderID ;

IF @@ERROR >0
SET @ExitMessage = N'Database Maintenance Failure TO UPDATE MaintHistHeader Records with Status of Complete: @MaintHistHeaderID = ' + CONVERT(nvarchar(40),@MaintHistHeaderID) + '';
GOTO Failure;



RETURN;
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-14 : 11:54:35
Also read the below

http://www.sommarskog.se/error-handling-I.html
Go to Top of Page
   

- Advertisement -