Outils pour utilisateurs

Outils du site


tips_informatiques:bases_de_donnees:ms-sql:t-sql:t-sql

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentes Révision précédente
Prochaine révision
Révision précédente
tips_informatiques:bases_de_donnees:ms-sql:t-sql:t-sql [2009/07/07 15:22]
nico
tips_informatiques:bases_de_donnees:ms-sql:t-sql:t-sql [2009/07/07 00:00] (Version actuelle)
Ligne 155: Ligne 155:
 ====== SELECT avec récursion ====== ====== SELECT avec récursion ======
  
-Having seen the basic syntax of a CTE and some its use cases in my last article, let us turn to the more interesting use: Recursive Queries. A recursive query is one in which a CTE references itself. What is the use of a recursive query? Well, all of us SQL Server 2000 users have always wanted to build hierarchical data. The most classical example is when you are given an organization structure and you wanted to represent the same in a relational database and run queries against it.+Having seen the basic syntax of a CTE (Common Table Expressions) ​and some its use cases in my last article, let us turn to the more interesting use: Recursive Queries. A recursive query is one in which a CTE references itself. What is the use of a recursive query? Well, all of us SQL Server 2000 users have always wanted to build hierarchical data. The most classical example is when you are given an organization structure and you wanted to represent the same in a relational database and run queries against it.
  
 In SQL Server 2000, there was no inherent way to perform hierarchical queries and people had different implementations. You can get dozens of them if you search GOOGLE. The SQL Server 2000 Books Online also had a topic called Expanding Hierarchies where a sample implementation was provided. With the advent of recursive queries however, we now have a standard implementation for working with hierarchical data and querying against it. In SQL Server 2000, there was no inherent way to perform hierarchical queries and people had different implementations. You can get dozens of them if you search GOOGLE. The SQL Server 2000 Books Online also had a topic called Expanding Hierarchies where a sample implementation was provided. With the advent of recursive queries however, we now have a standard implementation for working with hierarchical data and querying against it.
tips_informatiques/bases_de_donnees/ms-sql/t-sql/t-sql.1246972921.txt.gz · Dernière modification: 2009/07/07 00:00 (modification externe)