[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.sqlserver.programming

Why this CTE error? What am I doing wrong?

(Chris)

3/31/2007 5:08:00 PM

I can't get any CTE to work, even something this simple:

WITH ASDF AS
(
SELECT 123 as A
)


Every CTE I try to create gives me the same error:

Incorrect syntax near ')'
for the final ")"

Can anyone make a suggestion?

4 Answers

mesaalejandro

3/31/2007 5:13:00 PM

0

Try:

;WITH ASDF AS
(
SELECT 123 as A
)
select * from ASDF;


AMB

"cmay" <cmay@walshgroup.com> wrote in message
news:1175360852.308300.200310@d57g2000hsg.googlegroups.com...
>I can't get any CTE to work, even something this simple:
>
> WITH ASDF AS
> (
> SELECT 123 as A
> )
>
>
> Every CTE I try to create gives me the same error:
>
> Incorrect syntax near ')'
> for the final ")"
>
> Can anyone make a suggestion?
>


Roy Harvey

3/31/2007 5:30:00 PM

0

Just to cover the basics...

You are running SQL Server 2005?
The database is in compatability level 90?
The command also has a reference to the CTE, as well as the CTE
itself? I get the complaint about the closing parentheses if I run
just what was posted, but the following works as expected.

WITH ASDF AS
(
SELECT 123 as A
)
select * from ASDF

Roy Harvey
Beacon Falls, CT

On 31 Mar 2007 10:07:32 -0700, "cmay" <cmay@walshgroup.com> wrote:

>I can't get any CTE to work, even something this simple:
>
>WITH ASDF AS
> (
> SELECT 123 as A
> )
>
>
>Every CTE I try to create gives me the same error:
>
>Incorrect syntax near ')'
>for the final ")"
>
>Can anyone make a suggestion?

--CELKO--

3/31/2007 6:52:00 PM

0

>> Can anyone make a suggestion? <<

A CTE is a "Common TABLE Expression", so where is the query in your
example? The proprietary SELECT version of asignment is not a table
expression, nor will it port, nor does it make sense.



(Chris)

4/1/2007 12:40:00 AM

0

Yea I am stupid.

All I needed to do was add my select on at the bottom of the it and it
would have worked fine.