July 5, 2010 at 8:42 am
Good day everyone,
When I execute the stored procedure below I get this error: Conversion failed when converting the varchar value '10.00' to data type int.
So I'm casting the return value to varchar(18) which I don't think I should have to but regardless, I get the same result. I also tried convert with the same result. It seems so simple. What am I doing wrong?
CREATE PROCEDURE sp_Test
@person_id uniqueidentifier,
@bal varchar(18) output
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
SET NOCOUNT ON
--set @bal = '10.00'
set @bal = cast('10.00' as varchar(18))
return @bal
END
GO
Thanks
July 5, 2010 at 8:53 am
The problem is your RETURN statement, if you give it and argument to return it needs to be an integer value.
July 5, 2010 at 8:57 am
Thank you!
July 7, 2010 at 12:32 pm
When an output parameter is defined it is not necessary to explicitly return it using RETURN keyword. Just setting the OUTPUT variable's value as desired is enough.
CREATE PROCEDURE sp_Test
@person_id uniqueidentifier,
@bal varchar(18) output
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
SET NOCOUNT ON
set @bal = '10.00'
END
GO
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply