Decimal places not returning from a stored procedure

Posted on 2001-07-11
Last Modified: 2012-06-27
I have a stored procedure which should be returning a percentage back to the ASP page.

The problem is it is rounding up to the nearest whole number and not returning the decimal places.

The relevant parts of the stored procedure are as follows(the variable used to return the percentage is @result4):

CREATE PROCEDURE sp_highlevelsummaryrpt

@result4 int output
declare @discinc decimal

if (@discinc is null)
          set @discinc = '0'

set @discinc = (select Approved_Disc_Inc from pr_misc)

set @result4 = @discinc
select @result4

In the ASP page, I am showing the variable on the page as follows:

result4 = cmd_Execute_stored_procedure.Parameters("@result4")


I have tried changing the data type in the stored to float, numeric but none work.

Can anyone help??
Question by:obicham
  • 4
  • 3
  • 2
LVL 11

Expert Comment

ID: 6272822
you have declared your output variable (@result4) as an integer, therefore you will not get any decimalplaces returned.

try this: @return4 numeric(13,10)
LVL 11

Expert Comment

ID: 6272832
I meant @result4 off course, sorry...

Author Comment

ID: 6272847
That's a very good point but unfortunately it still doesn't work for some reason.

I tried declaring the output variable as decimal and a float but that won't work either
LVL 11

Expert Comment

ID: 6272881
set @discinc = (select Approved_Disc_Inc from pr_misc)

what type of field is Approved_Disc_Inc? And what does it contain?
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!


Author Comment

ID: 6272927
It is decimal(5) and it contains the value 1.75
LVL 11

Expert Comment

ID: 6272949
select Approved_Disc_Inc from pr_misc

does this return a single value? or multiple records? can you post more of your stored procedure?

Accepted Solution

John844 earned 50 total points
ID: 6273202
whenyou tried changing the datatype as mentioned above, did you also change the datatype of your command parameter?

Expert Comment

ID: 6273214
does the stored procedure display the proper values when you run it from query analyser?

I would also change this line to avoid any future problems if more records are added.
set @discinc = (select Approved_Disc_Inc from pr_misc)
set @discinc = (select TOP 1 Approved_Disc_Inc from pr_misc)

Author Comment

ID: 6276103
This is indeed where I was going wrong.

Thanks very much.

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now