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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 What is this structure called?

Author  Topic 

JacobPressures
Posting Yak Master

112 Posts

Posted - 2009-04-17 : 17:49:12
What is this structure called? I want to do more research on it to better understand it. It is later joined as one would a table in another query later in the script. Thanks!

WITH Guardian
AS
(
SELECT
sc.StudentID,
scp.LastName,
scp.FirstName,

ROW_NUMBER() OVER(PARTITION BY sc.StudentID ORDER BY scp.LastName, scp.FirstName) AS rn

FROM dbo.StudentContact sc
INNER JOIN dbo.Person scp ON scp.PersonID = sc.ContactID

WHERE sc.IsCustodian = 1

)

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2009-04-17 : 17:57:21
That's a CTE or Common Table Expression.
Go to Top of Page

JacobPressures
Posting Yak Master

112 Posts

Posted - 2009-04-17 : 18:08:35
Ok thanks! I'll look that up.
Go to Top of Page
   

- Advertisement -