Solved

# Stored Procedure won't return decimal

Posted on 2005-04-05
245 Views

Why won't this stored procedure return a decimal and what can I do to get a decimal back?

--Stored Procedure
alter procedure rjmTest6 (@z decimal(4,2) output)
As
Set NoCount On
Declare @x decimal(4,2)
Declare @y decimal(4,2)

Set  @x = 3.1
Set  @y = 4.5
Set  @z = @x / @y

print @z
Return

--Calling routine
declare @a decimal(5,1)
exec       @a = rjmTest6 @a
print       @a

--Results
0.69
0.0

0
Question by:scollege

LVL 68

Expert Comment

You are setting @a = to the return code from the proc (which is 0).  Try this instead:

declare @a decimal(5,1)
declare @rc int

exec      @rc = rjmTest6 @a
print      @a

0

LVL 6

Expert Comment

It should rather be:

declare @a decimal(5,1)
declare @rc int

exec      @rc = rjmTest6 @a OUTPUT
print      @a
0

LVL 68

Accepted Solution

Yes, I left off OUTPUT on the @a param; this is correct:

EXEC @rc = rjmTest6 @a OUTPUT
0

Author Comment

Thanks!
0

## Featured Post

In this article—a derivative of my DaytaBase.org blog post (http://daytabase.org/2011/06/18/what-week-is-it/)—I will explore a few different perspectives on which week today's date falls within using Microsoft SQL Server. First, to frame this stu…
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.