Decimals values from stored procedure

# Thread: Decimals values from stored procedure

1. Junior Member
Join Date
Dec 1969
Posts
6

## Decimals values from stored procedure

2. Senior Member
Join Date
Dec 1969
Posts
16,931

## RE: Decimals values from stored procedure

If you use adInteger, then you&#039;ve got NO chance of getting a decimal back. Try adSingle to start with.<BR><BR>I&#039;m no stored procedure buff, but do you have to declare a variable inside the SP and then return it? What is the type of that variable? That should also be a Single (or something similar).<BR><BR>Posting the contents of your SP may be a good idea (assuming it&#039;s not too huge!).<BR><BR>Craig.

3. Junior Member
Join Date
Dec 1969
Posts
6

## Heres the SP code

If I do an exec command the following line<BR>return(@sectorPercentageOfPortfolio)<BR><B R>returns a nice decimal in query manager.<BR><BR>i&#039;ve also tried using adSingle and many others decimal etc<BR><BR>CREATE PROCEDURE [dbo].[percentagesOfPortfolio] @currentTeam int, @currentSector int<BR>AS<BR><BR><BR>DECLARE @totalPortfolioValue as int<BR>DECLARE @currentSectorValue as int<BR>DECLARE @sectorPercentageOfPortfolio as float<BR><BR>SELECT @totalPortfolioValue = (SELECT SUM(amount * avgBuyPrice) FROM tblEquityHeld WHERE teamRef = @currentTeam)<BR>SELECT @currentSectorValue =<BR>(<BR>SELECT sum(amount*avgBuyPrice)<BR>FROM (tblEquityHeld INNER JOIN tblequity ON tblEquityHeld.equityRef = tblEquity.equityId)<BR>INNER JOIN tblsectors ON tblsectors.sectorID = tblEquity.sectorId <BR>WHERE teamref = @currentTeam AND tblsectors.sectorid = @currentSector<BR>GROUP BY tblsectors.sectorid<BR>)<BR><BR>SELECT @sectorPercentageOfPortfolio = @currentSectorValue / @totalPortfolioValue * 100<BR>SELECT @sectorPercentageOfPortfolio = CAST(@currentSectorValue AS FLOAT)/CAST(@totalPortfolioValue AS FLOAT) * 100 <BR><BR>return(@sectorPercentageOfPortfolio)<BR> GO

4. Junior Member
Join Date
Dec 1969
Posts
6