Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
magmo
Aged Yak Warrior
558 Posts |
Posted - 2006-08-05 : 08:44:07
|
| HiI have this stored procedure that show a sum of a shoppingcart.[dbo].[p_ShoppingCartTotal]( @UserID nvarchar(50), @TotalCost Decimal (9,2) OUTPUT)ASSET NOCOUNT ONSELECT @TotalCost = CAST(SUM(tbl_Products.ProductPrice * tbl_ShoppingCart.Quantity) AS decimal(9,2))FROM tbl_ShoppingCart, tbl_ProductsWHERE tbl_ShoppingCart.UserID = @UserID AND tbl_Products.NodeID = tbl_ShoppingCart.NodeIDI then use this line in my aspx page to display the output.MyTotalCommand.Parameters.Add("@TotalCost", SqlDbType.Decimal, (9.2)).Direction = ParameterDirection.OutputBut the problem is that even if the query should show for example 123,45 it never show any decimals.What am I doing wrong here?Best Regards |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-08-05 : 09:43:47
|
"But the problem is that even if the query should show for example 123,45 it never show any decimals."did you try this in Query Analyser ?you don't have to perform the CAST in your Stored Procedure. SQL Server will convert the result into data type of @TotalCost KH |
 |
|
|
magmo
Aged Yak Warrior
558 Posts |
Posted - 2006-08-05 : 09:53:06
|
| HiI guess not, but the problem is the same anyway. No decimals :-( |
 |
|
|
magmo
Aged Yak Warrior
558 Posts |
Posted - 2006-08-05 : 09:58:36
|
| :-) found the solution here.. http://support.microsoft.com/?kbid=892406This part fixed the problem.. SqlParameter pOut = cmd.Parameters.Add("@pOut", SqlDbType.Decimal); pOut.Precision = 19; pOut.Scale = 4; pOut.Direction = ParameterDirection.Output;Thought it might help others with the same problem.Cheers! |
 |
|
|
|
|
|