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.
Author |
Topic |
desikankannan
Posting Yak Master
152 Posts |
Posted - 2010-11-17 : 04:56:55
|
Hi,i try to working with exception handling with try and catch, but its not working, pls check my procedure,below iam sending table and procdure tableUSE [smartsystem]GO/****** Object: Table [dbo].[proctesting] Script Date: 11/17/2010 15:25:35 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOSET ANSI_PADDING ONGOCREATE TABLE [dbo].[proctesting]( [idu] [bigint] IDENTITY(1,1) NOT NULL, [testwork] [varchar](5) NULL, CONSTRAINT [PK_proctesting] PRIMARY KEY CLUSTERED ( [idu] ASC)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]) ON [PRIMARY]GOSET ANSI_PADDING OFFspUSE [smartsystem]GO/****** Object: StoredProcedure [dbo].[std_refmstdetail] Script Date: 11/17/2010 11:56:40 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOcreate procedure [dbo].[dotext](@testwork int )as set nocount onBEGIN TRYbegin transactioninsert into proctesting(testwork)values(@testwork) commit transactionEND TRYBEGIN CATCHIF @@TRANCOUNT > 0 ROLLBACK -- Raise an error with the details of the exception DECLARE @ErrMsg nvarchar(4000), @ErrSeverity int SELECT @ErrMsg ='workbring', @ErrSeverity = ERROR_SEVERITY() RAISERROR(@ErrMsg, @ErrSeverity, 1) END CATCHexec dotext 1,ddDesikankannan |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-11-17 : 05:04:30
|
There was nothing to execute because you are proving more input parameters as expected, hence the try catch isn't doing anything. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
desikankannan
Posting Yak Master
152 Posts |
Posted - 2010-11-17 : 06:14:39
|
quote: Originally posted by webfred There was nothing to execute because you are proving more input parameters as expected, hence the try catch isn't doing anything. No, you're never too old to Yak'n'Roll if you're too young to die.
pls iam getting, i wants to work with try and catch method in sqlpls check the above codeDesikankannan |
 |
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2010-11-17 : 06:23:59
|
quote: Originally posted by desikankannan
quote: Originally posted by webfred There was nothing to execute because you are proving more input parameters as expected, hence the try catch isn't doing anything. No, you're never too old to Yak'n'Roll if you're too young to die.
pls iam getting, i wants to work with try and catch method in sqlpls check the above codeDesikankannan
I am not sure whether it will work or not. Try it;Begin Tryexec dotext 1,dd --It will raise errorEnd TryBegin CatchPrint ERROR_MESSAGE() End catch |
 |
|
|
|
|
|
|