June 12, 2009 at 10:00 am
Hello All,
Please anybody let me know does SQL Server 2000 supports "WITH" clause. If no, then what's the substitue for "WITH" clause.
Thank You
June 12, 2009 at 10:09 am
do you mean using the WITH clause with a Common Table expression, or do you mean where you use the WITH clause to use a hint, like WITH(TABLOCKX)?
a CTE would get replaced with either a subquery or a temp table.
SELECT * FROM ([SELECT * FROM The_sql_that_used_to_be_in_a_CTE)
a hint featuring the WITH works in SQL2000 but was optional, and in 2005 it the WITH keyword became manditory:
select * from Invoices WITH(TABLOCKX)
select * from Invoices TABLOCKX
Lowell
June 12, 2009 at 11:11 am
I mean "with" clause with a common_table_expression in SQL Server 2000.
e.g. can I write as follows:
with x (startdate, enddate)
as
(
select ............
)
June 12, 2009 at 9:39 pm
No... SQL Server 2000 doesn't have WITH/CTE. Instead, use a "Derived Table" which is nearly identical in most cases. A derived table is just like a CTE in that it's a query that's used in a FROM clause as if its result set were a table. In other words, it's a subquery in the FROM clause just like a CTE is a subquery in the WITH clause. The format is...
[font="Courier New"] SELECT d.yada-yada
FROM (--===== derived table starts here
SELECT yada-yada
FROM sometable(s)
) d[/font]
In the above example, "d" is the table alias for the derived table.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply