Quantcast
Viewing all articles
Browse latest Browse all 207

What's the difference between a CTE and a Temp Table?

What is the difference between a Common Table Expression (CTE) and a temp table? And when should I use one over the other?

CTE

WITH cte (Column1, Column2, Column3)AS(    SELECT Column1, Column2, Column3    FROM SomeTable)SELECT * FROM cte

Temp Table

SELECT Column1, Column2, Column3INTO #tmpTableFROM SomeTableSELECT * FROM #tmpTable

Viewing all articles
Browse latest Browse all 207

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>