SQL Server, all about the Common Table Expressions (CTEs)
Hi friends! Today we talk about Common Table Expression which is much more often referred to with the acronym CTE . What are they? When someone ask me this question I answer using the simplest way I can define them : A CTE is a temporary Result set to which we associate a name and to which we can refer in the various statements. About the CTE CTEs were introduced few years ago with the release of the 2005 version of SQL Server. The goal was to provide an extended syntax that would allow you to write queries more easily . The basic syntax for using CTEs is really simple: it is sufficient to precede our INSERT, UPDATE or DELETE statement with the keyword WITH followed by the name we want to give to the Query, followed in turn by the keyword AS. A Simple example WITH MAXCODICE AS (SELECT MAX (CODE) AS CODE FROM LIST) SELECT * FROM MAXCODICE Very Very important: CTEs bring the ability to write recursive queries . We will therefore ...