Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Continuation of Message #1594531 - Use of WHERE
Message
From
22/02/2014 11:37:56
 
 
To
22/02/2014 04:54:11
Walter Meester
HoogkarspelNetherlands
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2008
Application:
Web
Miscellaneous
Thread ID:
01594922
Message ID:
01594940
Views:
42
Walter,

Thanks for the reply.

1) You're right, the ANSI format for dates is better. I have a bunch of demo examples where I should update that. Good point.

2) Speaking of ANSI standard, Common Table Expressions "are" part of the ANSI-99 standard. :)

CTEs are available in Oracle, MySQL, MS SQL (since 2005), and other DBs as well.

They are functionally equivalent of derived table expressions. Some developers love them, some don't. As for readable and maintainable, that's a matter of opinion.

Unfortunately, many online sites (and maybe even Wikipedia) refer to CTEs as "temporary named result sets". They're not result sets. It is simply a derived table subquery, placed "above" the outer query that refers to it. It's basically syntax sugar - some like it, some find it too heavy/sweet.

Yes, they are not a replacement for temp tables. If one needs to store a result set and then perform many subsequent operations beyond what a derived table subquery can do, then yes, a temp table will be better.

And yes, the recursive feature in CTEs is more complicated. I've only had to use the recursive feature a small # of times, but it sure came in handy.

3) I mentioned there are several solutions. Yes, as you wrote....this also works, and there will be developers who prefer this.
left outer     join  Purchasing.PurchaseOrderHeader AS POH  
               on Vend.BusinessEntityID = POH.VendorID  and OrderDate BETWEEN '1-1-2008' AND '12-31-2008'
The execution plans are the same.

Some developers prefer to only use the JOIN statement for keys, and some don't. We're talking preference, which IMO needs to be separated from functional benefit.

Thanks...
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform