It's a little complicated, but I'll try to explain.
The WITH clause is new to SQL Server 2005.
So, if your database is SQL 7 or SQL 2000, then you cannot use the WITH clause. Each version of SQL Server adds new functionality, which will sometimes cause applications to fail (because the new functionality may interfere with older code). I've never seen this happen, but it's possible. So... Each database has a compatibility level associated with it. If the compatibility level is 70, then it's set for SQL7 compatibility. If compatibility = 80, then it's SQL2000 compatible. If compatibility = 90, then it's SQL2005 compatible.
So... even is a database is attached to a sql 2005 server, it may be using an older compatibility mode, which would prevent your code from running.
I suppose a good google search would probably explain it better than I could.
When I run this... [tt][blue]sp_dbcmptlevel [MyDBName][/blue][/tt]
I get...
[tt][blue]The current compatibility level is 90.[/blue][/tt]
If your value is 70 or 80, then you won't be able to use the WITH clause. Also... if you are running in an older compatibility mode, I would strongly encourage you to find out why. Is this a 3rd party DB that only supports SQL2000? Are there other reasons, etc....
Does this make sense?
-George
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom