Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Decimal returning as Integer
Message
 
 
To
13/10/2010 09:08:40
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Environment versions
SQL Server:
SQL Server 2008
Miscellaneous
Thread ID:
01485249
Message ID:
01485251
Views:
32
>Hi,
>
>I have this stored procedure:
>
>
ALTER PROCEDURE [dbo].[PoliciesGetSuspenseAmount]
>(
>	@PolicyHeaderPK uniqueidentifier,
>	@SuspenseAmount decimal(18,2) OUTPUT
>)
>AS
>	SET NOCOUNT ON;
>	SELECT 
>		@SuspenseAmount = COALESCE(SUM(AmountReceived), 0.00)
>	FROM [dbo].[ReceiptDetails]
>	inner join [dbo].[Receipts] on ReceiptFK = ReceiptPK
>	WHERE 
>		([PolicyHeaderFK] = @PolicyHeaderPK
>		AND ReceiptTypeFK = 4)
>
>However, when I execute it it rounds my decimals to an integer. If the result should be 69.57 I get back 70.
>
>What have I done wrong?

What is the type of the AmountReceived column in the database? You can also try to cast to the desired type, e.g.
coalesce(cast(sum(AmountReceived as decimal (18,2)),0)
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform