April 2, 2015 at 3:49 pm
I am creating a stored proc
CREATE PROCEDURE [dbo].[uspUpdateabctable]
@var1 INT,
@var2 INT,
@var3 INT,
@DateTime1 VARCHAR(28),
@DateTime2 VARCHAR(28),
@vcErrorMsg VARCHAR(255),
@var4 BIGINT ,
@var5 BIGINT
AS
BEGIN -- SAVE TRANSACTION uspUpdateabctable
DECLARE
@iSEVERITY INT , -- User set severity level
@iSTATE INT -- Parameter in RAISERROR
@vcErrorMsg VARCHAR(255) /*******<-----IF I DEFINE THIS IT GIVES ME THE BELOW ERROR ELSE IT WORKS------>****/
SELECT
@iSEVERITY = 14, -- Default user severity level
@iSTATE = 1, -- Default state - DON''T CHANGE
@vcErrorMsg = 'OK'
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
SET NOCOUNT ON
BEGIN TRY
UPDATE [dbo].[abctable]
SETCol1 = @var4 ,
CDATE_TIME = CONVERT(DATETIME, @DateTime1 )
WHERE ODATE_TIME = CONVERT(DATETIME, @DateTime1)
ANDpID = @var2
ANDFNO = @var3
COMMIT TRANSACTION;
END TRY
BEGIN CATCH
IF @@TRANCOUNT > 0
ROLLBACK TRANSACTION;
/********************************************/
/* Throw Error */
/********************************************/
IF(@vcErrorMsg <> ERROR_MESSAGE())
BEGIN
SELECT @vcErrorMsg = 'uspAddressByIDGet: ' + @vcErrorMsg + ERROR_MESSAGE(),
@iSEVERITY = ERROR_SEVERITY(),
@iSTATE = ERROR_STATE()
END
RAISERROR(@vcErrorMsg,@iSEVERITY,@iSTATE)
RETURN
END CATCH
END
GO
ERROR MESSAGE
Msg 134, Level 15, State 1, Procedure uspUpdateLaneOperation, Line 49
The variable name '@vcErrorMsg' has already been declared. Variable names must be unique within a query batch or stored procedure.
but when I try to create a stored proc by the below code it works fine
BEGIN
DECLARE
@iSEVERITY INT , -- User set severity level
@iSTATE INT , -- Parameter in RAISERROR
@vcErrorMsg VARCHAR(255)
SELECT
@iSEVERITY = 14, -- Default user severity level
@iSTATE = 1, -- Default state - DON''T CHANGE
@vcErrorMsg = 'OK'
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
SET NOCOUNT ON
BEGIN TRY
April 2, 2015 at 3:55 pm
Can someone help me
as in why is this happening
April 2, 2015 at 11:04 pm
You can't declare @vcErrorMsg as a variable being passed to the proc, then again within the proc. Delete the second one and it should work.
April 3, 2015 at 12:32 am
What I do last week a tragic a lot of water but at the Stillwater to flush out any impurities my by the last two days I watch my sodium intake mostly by cutting out foods like a quite such a high amount of sodium and that's about it the two days before the show and Enduros Male Enhancement[/url] that's all I do dishes cooking steaming away some orangery very I am just as I was a kid I set a new standard in this for we have to be almost all to rate this to a point where now I have to live up to my standards if I come in a show slightly off even on still more ripped than the other competitors from not it's Barry ripped me some smooth see many bodybuilders you know.
For information presentation topics --> > >> > > > http://testolimitfacts.com/enduros-male-enhancement/
April 3, 2015 at 8:11 am
Quick thought, recommend adding a check for error message 1205 and a retry in case of a deadlock
😎
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply