Data Browser - Viewing Site  Sector 23 Code Bank Logged in as:  Guest  




           


SQL With Clause Example
Example of using 'With' clause to hold a subquery to use later in the query:
(example using SQL Server 2010)

WITH SubqueryData AS
(
Select Id, Name From MyData
)
SELECT * FROM SubqueryData

> >

"With" must be the first command in your query; otherwise it must follow a semicolon.
(or you get the error: Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon.)

Created By: amos 6/10/2013 2:16:35 PM
Updated: 6/10/2013 2:17:51 PM