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 8619949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:27:48+00:00 2026-06-12T06:27:48+00:00

I have this razor statement sql = SELECT * FROM CarBike + Order By

  • 0

I have this razor statement

sql = "SELECT * FROM CarBike" +
       "Order By id OFFSET @0 ROWS FETCH NEXT @1 ROWS ;";

var result = db.Query(sql, offset, pageSize);

i am getting error

Incorrect syntax near the keyword 'By'.
Invalid usage of the option NEXT in the FETCH statement.

System.Data.SqlClient.SqlException: Incorrect syntax near the keyword 'By'.
Invalid usage of the option NEXT in the FETCH statement.

Please help me to correct this error

  • 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-06-12T06:27:50+00:00Added an answer on June 12, 2026 at 6:27 am

    You need a space between CarBike and Order by

    sql = "SELECT * FROM CarBike" + 
       " Order By id OFFSET @0 ROWS FETCH NEXT @1 ROWS ;"; 
    

    NB: OFFSET/FETCH is SQL 2012+ only.

    To achieve similar results in previous versions

    select * from
    (
    select *, ROW_NUMBER() over (order by id) rn
    from CarBike
    ) v
    where rn between @0+1 and @0+@1
    order by id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code in mvc 3 razor @using (Html.BeginForm(MyAction, MyController)) { <input type=text
Have this query: SELECT HOUR( DATE ) AS hr, COUNT( * ) AS cnt
I have this Razor Template <table> <tr> <td>@Html.RadioButtonFor(i => i.Value, 1)</td> <td>@Html.LabelFor(i => i.Value,
Not having much luck, I have the following if/else statement in Razor which works
I'm new to MVC Razor. I have this view: @model SuburbanCustPortal.Models.CustomerModel @{ ViewBag.Title =
Hello guys I have this weird problem with Razor Syntax. I have written the
I have this razor line, the editor shows a syntax error but it works
I have this line in my view.aspx I am not using razor: <p style=color:Red>
I am new to MVC Razor and I have this problem Ex: I want
I have this line in my razor view. @String.Format("{0:C}", @price) I want it to

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.