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 |
|
alecd
Starting Member
7 Posts |
Posted - 2011-03-09 : 01:41:36
|
| hello,I'm trying to use a parameter in a math equation, but it doesn't seem to be working. SET Price = Price * @Percentage@Percentage is a decimal parameter passed to the sql statement.Why is this not working?Thanks,Alec |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-03-09 : 01:44:08
|
what is Price ? is it a column in your table ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
alecd
Starting Member
7 Posts |
Posted - 2011-03-09 : 01:50:20
|
| Procedure UpdateCart( @Percentage as decimal, @CartId as int)AsUPDATE _CartSET Price = Price * @PercentageWHERE CartId = @CartId |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-03-09 : 01:52:54
|
you didn't define any precision & scale for the @percentage decimal data type it will be default to integerso if you pass in @percentage as 1.25, it will be treated as 1. That's why it is not working. KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
alecd
Starting Member
7 Posts |
Posted - 2011-03-09 : 02:03:18
|
| still not working. I defined the decimal as: @Percentage decimal (8, 2) |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-03-09 : 02:15:29
|
please explain exactly what is not working ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
alecd
Starting Member
7 Posts |
Posted - 2011-03-09 : 02:15:56
|
| Never mind..... My sql execute definition was wrong..... Thanks khtan! |
 |
|
|
|
|
|
|
|