>Hi Sergey, I need the case in the Where clause not the set, the same fields will always be updated with the same values , what I have is a table containing a customer number and a master customer number, if @MyFlag = 'Y' then I want to update all records for that master , i.e my where clause would be: "Where MasterNumber = @MasterNumber" otherwise the where clause would be:"Where CustomerNo = @CustomerNo" which would only update one record - thanks a lot
It's not even close to your original post. Anyway, I'm not sure why it has to be in where clause
IF @MyFlag = 'Y'
update mytable
SET fieldx = NULL
WHERE MasterNumber = @MasterNumber
ELSE
update mytable
SET fieldx = NULL
WHERE CustomerNo = @CustomerNo
--sb--