October 17, 2007 at 1:17 am
CREATE PROC Reg_Get
AS
BEGIN
EXEC master.dbo.xp_regenumkeys ‘HKEY_LOCAL_MACHINE’,'SOFTWARE\ISS\CPE’
IF @@ERROR 0
BEGIN
RAISERROR (’Key doesnt exists ‘,10,1 )
RETURN 1
END
RETURN 0
END
GO
– Calling Script
EXEC Reg_Get
– Result
Msg 22001, Level 16, State 1, Line 0
RegOpenKeyEx() returned error 2, ‘The system cannot find the file specified.’
I want to trap above error without using TRY..CATCH. So that It can support to SQL Server 2000 also
October 17, 2007 at 6:31 am
You can't trap errors in 2000. TRY/CATCH was introduced in 2005 in order to provide error trapping.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
October 17, 2007 at 8:01 pm
Out of curiosity, why are you doing this through SQL Server? The extended stored procedure xp_regread isn't supported for use by normal processes. Is there a reason you aren't reading the registry using a script or small application?
K. Brian Kelley
@kbriankelley
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply