Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hello Guys,

I'm trying to create a CTE, but facing this issue while creating. Can anyone please guide me on this.

What I have tried:

SQL
;WITH myCTE(fname , lname) 
as(
select fname,lname from myTable
)
select * from myCTE
Posted
Updated 16-Oct-19 3:19am
v3
Comments
ZurdoDev 16-Oct-19 10:00am    
I don't get the error, which tells me you haven't posted the full sql that is giving you the error.

1 solution

Try using the same name in both places:
SQL
WITH myCTE(fname , lname) 
AS(
SELECT fname,lname FROM myTable
)
SELECT * FROM myCTE
 
Share this answer
 
Comments
srko 16-Oct-19 9:18am    
@OriginalGriff tried the same thing but is not working, will this be due to SSMMS support?
ZurdoDev 16-Oct-19 10:01am    
Try using the same name in both places:
I must be blind. The only difference from what OP posted and what you posted is you omitted the semi-colon.
[no name] 16-Oct-19 10:03am    
Check the versions of the question :)
ZurdoDev 16-Oct-19 10:08am    
I thought about that but was too lazy. However, that still won't give the error the OP posted. But it would fix the original problem.
srko 16-Oct-19 10:22am    
Yes guys, i have updated the question.
Removed ;
changed the name of the CTE.

tried the both, but is not working

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900