Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Finding Missing Records
Message
 
 
To
31/10/2017 13:53:54
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2012
Miscellaneous
Thread ID:
01655302
Message ID:
01655308
Views:
31
>Thanks, it looks like that is in effect the same thing I posted as seeming to work. Is there any advantage to using the CTE version over my plain and simple version?
>
>>I misread your original requirement
>>
>>;with allCombinations as (select I.*, B.* from Items I, Branches B)
>>
>>select AC.* from allCombinations AC where not exist (select 1 from BranchItems BI where BI.ItemId = AC.ItemID and BI.BranchId = AC.BranchID)
>>
The exists part in your query should be simplified (e.g. just use BrachItems as I did). Other than that I used CTE for clarification and maintenance point only - no need to use CTE and you can use it directly.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform