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 |
|
issammansour
Yak Posting Veteran
51 Posts |
Posted - 2007-10-12 : 09:00:20
|
| I try to declare a variable with un static decimal point in the following statement:-declare @mpt int;declare @mpq nvarchar (1)SELECT @mpq = (SELECT mpq FROM ims.parm)exec('declare @MM1 decimal (10,'+ @mpq +');')set @mm1 = 1print @mptwhen i print the declare statement looks like the following:declare @MM1 decimal (10,2);but with exec the statement, I have the following error:-Msg 137, Level 15, State 1, Line 18Must declare the scalar variable "@mm1".Best regards |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2007-10-12 : 09:31:59
|
| >> I try to declare a variable with un static decimal point ...Why the heck are you doing this? For formatting? Don't format data in SQL, just return it and let your client format it. If it is for mathematical purposes, just use decimals at the highest precision that you need, and round the results to a lower precision (where necessary) using basic math.If you can be more specific about what you are trying to do, we can certainly give you better ways to do it rather than what you are trying. You are making something probably quite simple extremely convoluted and complicated...- Jeffhttp://weblogs.sqlteam.com/JeffS |
 |
|
|
|
|
|