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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 do these do the same thing?

Author  Topic 

chedderslam
Posting Yak Master

223 Posts

Posted - 2009-06-08 : 17:49:55
I have this now:

if (
(select policy_state
from pos_policy
where pos_id = @pos_id) = 'OR'
and @company = 5
)
begin
update @violations
set points = 0
where conviction_date is null
end

The senior developer wants one UPDATE statement. Will this do the same thing?:

update @violations
set points = 0
where conviction_date is null
and (select policy_state
from pos_policy
where pos_id = @pos_id) = 'OR'
and @company = 5

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-06-08 : 18:24:10
The original statemen is only one update.
What is your senior developers goal here?



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

chedderslam
Posting Yak Master

223 Posts

Posted - 2009-06-09 : 09:18:17
I think he wants a single statement. Will the second version work properly?
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-06-09 : 09:29:35
Yes it looks like doing exact the same.
You can do a test to be sure about that.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

chedderslam
Posting Yak Master

223 Posts

Posted - 2009-06-09 : 09:33:03
Thanks for the help guys.
Go to Top of Page
   

- Advertisement -