April 25, 2008 at 10:41 am
Is it possible to rewrite the following query to NOT use the <> and achieve same result and better perfromance
update tblTest_Results set status=1
where id<>@ID
Thanks
April 25, 2008 at 11:27 am
I think the only thing you can do is to add [font="Courier New"]AND Status <> 1[/font] to the WHERE clause, so you don't re-update rows that already have the value (unless you are explicitly trying to fire an update trigger)
Eddie Wuerch
MCM: SQL
April 25, 2008 at 12:32 pm
Can rows be 0 or negative? If not, you could make it status > 1.
Or do two updates with > 1 and < 1 as the clauses, which could run quicker.
April 25, 2008 at 12:55 pm
If you are thinking of addin the STATUS <> 1 clause and the status column can contain nulls you might want to try ( STATUS <> 1 or STATUS IS NULL ) instead.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply