SQLTeam.com | Weblogs | Forums

How to correct this code


#1

declare @Teil_3147 numeric(18,0)
hello

i wrote this code but i have problem it says i should declare the variable can you help please?

select @Teil_3147=Lager_Bestand_Aktuell
FROM [Reporting].[dbo].[Teile_Bestand]
where Teil_Nummer like '4700' and Lager like 'I'

update dbo.I_Fast_Inv_Adjustments_charts
set Teil_3147= (@Teil_3147*0,0111)
where dbo.I_Fast_Inv_Adjustments_charts.Datum
=CONVERT(date, getdate())


#2

What are you trying to do here? A column cannot be set to a tuple or array or whatever that is.

SET Teil_3147 = (@Teil_3147 * 0, 0111 )

Or do you mean:

SET Teil_3147 = (@Teil_3147 * 0.0111 )

with a decimal point?


#3

sorry but i am new to sql server
what is difference between waht you wrote
i want to use the valöue of the variable that i saved here to save in a column in a table


#4

This is not about SQL Server per se. It's about basic math. In your code you are saying that Teil_3147 should be set to the variable @Teil_3147 times 0. Then there is ', 0111' on the end of that. In math

a = b * 0, 0111

doesn't mean anything. however, this is meaningful:

a = b*0.0111

If you just want to save the value of the variable to the column then all you need is:

SET Teil_3147 = @Teil_3147

#5

gbritton, I believe the problem arises from where mana is they normally use the comma "," as the decimal point indicator, while I believe SQL Server might be looking for the period "." as you say.

mana, please try the period and see if that helps.