SQL INDONESIA

Personal Notes of Edwin Eu

SQL Server – Common Table Expression (CTE)

SQL Server  – Common Table Expression (CTE)

  • Common Table Expression (CTE) was implemented in SQL Server 2005
  • CTE are not design to be a replacement of the Temp Table
  • CTE declare the name at the beginning of code  with keyword “WITH EmpSort_CTE AS
  • CTE exampleWITH EmpSort AS

 (SELECT FirstName, LastName, EmpID, LocationID,
 ROW_NUMBER() OVER (ORDER BY LastName, FirstName) AS Position
 FROM Employee)
SELECT * FROM EmpSort
GO

Leave a comment

Navigation

About

Writing on the Wall is a newsletter for freelance writers seeking inspiration, advice, and support on their creative journey.