February 9, 2006 at 1:47 pm
Hi,
I have this update statement,
UPDATE products SET productdetail = @detail, productprice = @price WHERE productid = @id.
Sometimes the value of @price will be null. For those cases, I don't want to update the price, I want to update only the detail. Is it possible to do in one single statement. I can do two updates, update detail followed by update price if price not null. But I would like to know if there is any other way to do it.
Thanks.
February 9, 2006 at 1:56 pm
No but I still want to update the detail even if the price is null. I think the above statement either updates both detail and price or updates neither.
February 9, 2006 at 2:06 pm
This is what I initially thought of. Its part of a big stored procedure. I am just curious if I can do it in one statement, to reduce the clutter. I guess not. Thanks.
February 9, 2006 at 2:10 pm
UPDATE products
SET productdetail = @detail,
productprice = ISNULL(@price, productprice)
WHERE productid = @id.
_____________
Code for TallyGenerator
Viewing 7 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply