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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Updating a column with truncation if above value

Author  Topic 

Lionheart
Starting Member

41 Posts

Posted - 2009-10-09 : 14:30:40
I need to update a column of values in a table using a calculation, but truncate the value at a maximum.

At the moment I have the following code.

Update Event
set Value = Value * (VariableA/VariableB)


What I need to do is set it so that if the value is above 130M then it truncates at 130M and inserts that value.

Thx

LH

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-10-09 : 14:36:17
do you mean this?

Update Event
set Value = case when Value * (VariableA/VariableB) >yourquantity then yourquantity else Value * (VariableA/VariableB) end
Go to Top of Page

Lionheart
Starting Member

41 Posts

Posted - 2009-10-09 : 14:38:02
That's exactly what I mean. Thanks very much.

LH
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-10-09 : 14:41:19
welcome
Go to Top of Page
   

- Advertisement -