September 1, 2015 at 2:49 pm
Jeff Moden (8/30/2015)
and not exists (select * from ContractorCoverageException cce where cce.contractorcoverageid = a.id and postalid = postal.id)
Thank you Sir.:-)
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
September 2, 2015 at 8:49 am
kim / data detection group (9/1/2015)
... and of course, you have a suitable (unique? clustered? as appropriate) index on ContractorCoverageException, like:... ContractorCoverageException (contractorcoverageid, postalid)
or
... ContractorCoverageException (contractorcoverageid) include (postalid)
Thank you.:-)
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
September 2, 2015 at 9:07 am
Jeff Moden (8/28/2015)
Before you go to all that trouble, try changing "postalid" to "*" or "1" in the not exists and see what happens.
That won't do anything. The SELECT list for an exists is completely ignored, it's not processed in any way. You can put SELECT 1/0 in an EXISTS and it'll still run fine.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
September 2, 2015 at 10:54 am
GilaMonster (9/2/2015)
Jeff Moden (8/28/2015)
Before you go to all that trouble, try changing "postalid" to "*" or "1" in the not exists and see what happens.That won't do anything. The SELECT list for an exists is completely ignored, it's not processed in any way. You can put SELECT 1/0 in an EXISTS and it'll still run fine.
Thanks for dispelling another old myth, Gail. :blush: I'm embarrassed to admit that I've never tested the myth. That 1/0 thing looks like a way to have some fun with someone's mind. 🙂
--Jeff Moden
Change is inevitable... Change for the better is not.
September 2, 2015 at 11:10 am
Jeff Moden (9/2/2015)
GilaMonster (9/2/2015)
Jeff Moden (8/28/2015)
Before you go to all that trouble, try changing "postalid" to "*" or "1" in the not exists and see what happens.That won't do anything. The SELECT list for an exists is completely ignored, it's not processed in any way. You can put SELECT 1/0 in an EXISTS and it'll still run fine.
Thanks for dispelling another old myth, Gail. :blush: I'm embarrassed to admit that I've never tested the myth. That 1/0 thing looks like a way to have some fun with someone's mind. 🙂
Yes it does, and it happened to me. :hehe:
Gail, you posted something like that somewhere before and I thought it was the most counter-intuitive thing I'd seen in a long time. It does, however, illustrate the point very clearly and I thought the way you proved it with the 1 / 0 was brilliant. I tested it several different ways and tried to find that post again to compliment you on your proof, but I couldn't find the thread.
Since it's come up again here, I have another chance. Thank you for the irrefutable proof. Very nicely illustrated.
Viewing 5 posts - 16 through 19 (of 19 total)
You must be logged in to reply to this topic. Login to reply