Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4018428
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:58:54+00:00 2026-05-20T09:58:54+00:00

Hi can you please help me with this, Im using SQL Server 2005, im

  • 0

Hi can you please help me with this, Im using SQL Server 2005, im getting the “Incorrect syntax near the keyword ‘WITH'” error, Thanks

create table #Act(
iAId int, 
iPAID int, 
sResource nvarchar(10), 
sName nvarchar(50), 
W1 int, 
W2 int, 
W3 int)

    INSERT INTO #Act (iAId, iPAID, sResource, sName, W1, W2, W3)
        SELECT AC00000.iAId, AC00000.iPAID, AC00000.sResource, 
               Activities.sName, WK00000.W1, WK00000.W2, WK00000.W3
        FROM   AC00000 INNER JOIN
               Activities ON AC00000.iActTypeId = Activities.iActivityId INNER JOIN
               WK00000 ON AC00000.iAId = WK00000.iAId
    ;WITH acts (iAId, iPAID, sResource, sName, W1, W2, W3) AS
    (
         SELECT parent.iAId, 
                parent.iPAID,
                parent.sResource, 
                parent.sName, 
                parent.W1, 
                parent.W2, 
                parent.W3
         FROM   #Act parent
         WHERE iPAID is null

         union all

         SELECT child.iAId, 
                child.iPAID,
                child.sResource, 
                child.sName, 
                child.W1, 
                child.W2, 
                child.W3
         FROM   #Act child

        join acts
        on child.iPAID = acts.iAID
    )
    select * from acts
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T09:58:55+00:00Added an answer on May 20, 2026 at 9:58 am

    WITH (Common table expressions) only works in SQL Server 2005 or above.

    Even at compatibility level 80, WITH statements work in SQL Server 2005.

    • Check that you are not running SSMS 2005 against a SQL Server 2000 instance.
    • Check that your server has only one instance of SQL Server, and it is the 2005 instance.
    • run this to check

    select @@version
    

    Your exact error text comes up when you use “with” against SQL Server 2000

    Msg 156, Level 15, State 1, Line 2
    Incorrect syntax near the keyword ‘with’.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi Guys can you please help me with this error? What is it? Server
I am using SQL Server 2005, please tell me how can I get 6
I'm trying to configure replication on SQL Server 2005. I can do it using
Maybe this cannot be done, but please help or suggest how this can be
[using SQL Server 2005] I have a table full of users, I want to
I've created a web enabled database using SQL Server 2005 to store the data
Can someone please help me out with printing the contents of an IFrame via
I'm doing module to save and retrieve images using SQL server database 2008 and
Please help me figure this out. I apologize if this is a duplicate question,
When I try to connect to the sql server using the sqlcmd utility, I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.