Wednesday, June 20, 2007

SQL Server @ Derived Tables

Derived Tables:

The derived tables are just like the temporary tables in SQL Server,
these are created on the fly by using the SELECT statement and
these reflect similar as of the temporary tables or views.

A derived table is created in the memory on the fly and only the
outer SELECT query can have its reference.

The syntax us like :

SELECT * FROM ( SELECT * FROM table_name) AS alias

NOTE: The alias at the end is part of the syntax and it is necessary.
Otherwise you will face an syntax Error.

The concept of Derived Tables was introduced in the SQL Server 2000,
Now in SQL server 2005 the similar and little advanced concept is
introduced with the name of COMMON TABLE EXPRESSIONS for
RECURSIVE QUERIES. Hopefully I will post on this concept sooner.


No comments: