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

  • SEARCH
  • Home
  • 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 993599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:26:56+00:00 2026-05-16T06:26:56+00:00

I have a legacy web-site that I am maintaining (built mostly in classic ASP

  • 0

I have a legacy web-site that I am maintaining (built mostly in classic ASP with vbscript). I am making some modifications to it, and got tired of waiting 5 minutes everytime I had to go through one of the pages that was loading 99000 records from the database before displaying the first 20 of them, so I rewrote the code as:

sSQL = "WITH OrderedAgreements AS (SELECT *, ROW_NUMBER() OVER (ORDER BY " & strSort & ") AS 'RowNumber' FROM ServiceAgreement " & WhereClause & ")"
sSQL = sSQL & " SELECT * FROM OrderedAgreements WHERE RowNumber BETWEEN " & iStartRec & " AND " & iStartRec + iPageSize - 1
Set rs = Server.CreateObject("ADODB.Recordset")

rs.Open sSQL, SQLConn, adOpenStatic, adLockReadOnly

(the objective being to return only the rows that will actually be displayed).

This runs fine when run from IIS-7 on my local development machine (Windows 7). It is accessing a test database under SQL Server 2008 on a development server in an adjacent lab.

However, when I run the identical code in a beta site on the production server (i.e., a parallel directory tree to the production site, accessed through a different HTTP port), it gives me a “syntax error near keyword ‘WITH'”

The production server is running Windows Server 2003 R2 and IIS 6, but I can’t think of a reason why that should cause an error on one machine and not on the other. They are running identical code, connecting to the same database, accessed with the same sequence of command. I even put some logging code in to output the SQL that is being generated, and it is identical in both cases. Both machines are running the 2.0/3.0/3.5 framework. Both machines have SQL Server 2008 installed.

The production server is accessible to me (via RDP), but it does not have Visual Studio on it. I am pretty much at my wits end as to figuring out why the same code is getting an SQL syntax error on one machine and not the other.

Can anyone give me a clue as to how to proceed?
Thanks.

  • 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-16T06:26:57+00:00Added an answer on May 16, 2026 at 6:26 am

    Options. in order of likelihood…

    • What is the DB compat level? sp_helpdb will show you. You need to be 90 or above to use a CTE

    • What does SELECT @@VERSION say on both SQL Servers? Really both ‘2008?

    • Try ;WITH... in case you have an extra SQL command before the CTE

    An observation… why not use parameters rather the string concatenation?

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

Sidebar

Related Questions

I have a legacy ASP web site that uses the treeview control from COMCTL32.OCX.
I have a web-site that generates some simple tabular data as html tables, many
I have a web site that built on Visual studio 2008 and i need
I've been dealing with a legacy asp.net 2.0 web site that was originally setup
I have a legacy (haha) ASP.Net Webforms Web Site Project in Visual Studio 2008
I have an web application written in ASP.NET (FW 3.5) (along with some VBScript,
We have a classic VBScript default.asp page in the root of our site. (This
I have an unconventional legacy asp.net 1.1 web app that uses the src attribute
We have some legacy code that needs to identify in the Page_Load which event
I have a legacy VB6 application that was built using MSDE. As many client's

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.