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
 Update statment

Author  Topic 

Vack
Aged Yak Warrior

530 Posts

Posted - 2008-10-17 : 14:34:53
For some reason my statement below is not working. Am I missing something?

Summing up ext_rebate in orderrebate file and updating the unit_price field with that amount in the oeordlin file. Only want to update records with a line_no = 9999



BEGIN
update oeordlin_sql
set unit_price = (select A.sumExt_rebate
from(select Ord_no,sum(ext_rebate)
as sumExt_Rebate from Orderrebate
group by ord_no)A
where A.ord_no = oeordlin_sql.ord_no)
from orderrebate join oeordlin_sql on orderrebate.ord_type = oeordlin_sql.ord_type and
orderrebate.ord_no = oeordlin_sql.ord_no and orderrebate.cus_no = oeordlin_sql.cus_no
where oeordlin_sql.line_no = 9999 and oeordlin_sql.item_desc_2 <>'CHANGE'
END

Vack
Aged Yak Warrior

530 Posts

Posted - 2008-10-17 : 14:47:57
After a little testing it works if I take out:
and oeordlin_sql.item_desc_2 <> 'CHANGE'

But I'm not sure why. that field is Char(30)
What I'm trying to accomplish is if someone makes a change to a line they need to type CHANGE in description 2. If that exists I don't want that line updated.
Go to Top of Page

hanbingl
Aged Yak Warrior

652 Posts

Posted - 2008-10-17 : 15:42:16
ISNULL(oeordlin_sql.item_desc_2 ,'') <> 'CHANGE'
Go to Top of Page
   

- Advertisement -