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.
Author |
Topic |
maddyslayer
Yak Posting Veteran
57 Posts |
Posted - 2013-05-15 : 15:52:14
|
Here's the if exists statement i wrote in a stored procedure, Is this efficient? Is there are a better way so there is not much of a delay? Any suggestions are appreciated.If Exists (select * from products where product_id = @id and prod_cd in (select prod_cd from prod where prod_type = 'toys' and prod_Active = 'Y')and prod_state = 'Y') update CUSTOMER set FLAG = 'Y',DATE = GETDATE() where product_id = @id and EMAIL_ADDRESS = @EMAIL else update CUSTOMER set FLAG = 'N',DATE = GETDATE() where product_id = @id and EMAIL_ADDRESS = @EMAIL |
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2013-05-15 : 17:58:44
|
Have you looked at the execution plan to see where the time is being spent and what indexes are being used?=================================================I am not one of those who in expressing opinions confine themselves to facts. (Mark Twain) |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-05-16 : 00:24:08
|
i would have replaced in with join or using EXISTS------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|