Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

CTE Expand / Collapse
Author
Message
Posted Saturday, September 7, 2013 6:24 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Sunday, April 27, 2014 5:30 AM
Points: 1, Visits: 18
in Which Sensory we use CTE
Post #1492520
Posted Saturday, September 7, 2013 6:51 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Tuesday, October 14, 2014 10:58 AM
Points: 5,333, Visits: 25,272
You might want to start by reading this:

http://www.4guysfromrolla.com/webtech/071906-1.shtml

and then if you have specific questions ask those questions in a new posting.


If everything seems to be going well, you have obviously overlooked something.

Ron

Please help us, help you -before posting a question please read

Before posting a performance problem please read
Post #1492522
Posted Saturday, September 7, 2013 7:14 PM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Sunday, September 29, 2013 1:24 AM
Points: 429, Visits: 1,721
coolrana.kumar69 (9/7/2013)
in Which Sensory we use CTE

I use CTEs now routinely instead of using sub-queries. Just a new way of doing it that seems more clear and structured to me.

So, instead of:


SELECT
r.Val
FROM
someTable AS r
WHERE
r.Val IN
(SELECT foo FROM someOtherTable)


Using CTE:


WITH
cteTest (foo)
AS (
SELECT foo FROM someOtherTable
),
cteResult (val)
AS (
SELECT
r.val
,t.foo
FROM someTable AS r
INNER JOIN cteTest AS t
ON r.val = t.foo
)
SELECT * FROM cteResult


CTEs can also be written to do recursive queries and that is a more complex subject.

 
Post #1492572
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse