?
Solved

Stored Procedure won't return decimal

Posted on 2005-04-05
4
Medium Priority
?
262 Views
Last Modified: 2012-08-13

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
Comment
Question by:scollege
  • 2
4 Comments
 
LVL 70

Expert Comment

by:Scott Pletcher
ID: 13712240
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

by:graf0
ID: 13715301
It should rather be:

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

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

Accepted Solution

by:
Scott Pletcher earned 150 total points
ID: 13716732
Yes, I left off OUTPUT on the @a param; this is correct:

EXEC @rc = rjmTest6 @a OUTPUT
0
 

Author Comment

by:scollege
ID: 13717099
Thanks!
0

Featured Post

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question