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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:32:45+00:00 2026-06-04T20:32:45+00:00

DECLARE @startRowIndex int set @startRowIndex=0 Declare @maximumRows int set @maximumRows=5 SET ROWCOUNT 5; WITH

  • 0
DECLARE @startRowIndex int  
  set @startRowIndex=0
  Declare @maximumRows int 
  set @maximumRows=5

SET ROWCOUNT 5;

WITH OrderedEmployees As

SELECT *, ROW_NUMBER() OVER (Order By EmployeeID ASC) as RowNum FROM Employees 

 SELECT * FROM OrderedEmployees Where RowNum > @startRowIndex
 Order By EmployeeID ASC

I got this query from a website but when I run it in SQL Server Management Studio, it gives me the following error please help me out, I have intuition that its just a syntax mistake that is stumping me here , please help me out

Msg 156, Level 15, State 1, Line 10
Incorrect syntax near the keyword ‘SELECT’

  • 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-04T20:32:46+00:00Added an answer on June 4, 2026 at 8:32 pm

    I believe that this is what you want:

    DECLARE @startRowIndex int  
      set @startRowIndex=0
      Declare @maximumRows int 
      set @maximumRows=5
    
    SET ROWCOUNT 5
    
    ;WITH OrderedEmployees As
    (
        SELECT *, ROW_NUMBER() OVER (Order By EmployeeID ASC) as RowNum 
        FROM Employees 
    )
    SELECT * 
    FROM OrderedEmployees 
    Where RowNum > @startRowIndex
    Order By EmployeeID ASC
    

    Though, I don’t really know why you are choosing to use ROWCOUNT instead of just filtering your CTE. I would use:

    DECLARE @startRowIndex int  
      set @startRowIndex=0
      Declare @maximumRows int 
      set @maximumRows=5
    
    ;WITH OrderedEmployees As
    (
        SELECT *, ROW_NUMBER() OVER (Order By EmployeeID ASC) as RowNum 
        FROM Employees 
    )
    SELECT * 
    FROM OrderedEmployees 
    Where RowNum > @startRowIndex AND RowNum <= @maximumRows
    Order By EmployeeID ASC
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

declare @top int set @top = 5 select top @top * from tablename Is
DECLARE @TotalMaxQty int SET @TotalMaxQty = 1000 SELECT PKId ,Qty FROM dbo.Sales PKId Qty
declare @i int declare @skool float declare schoolCursor cursor for select distinct choice from
DECLARE @Symb varchar SET @Symb = 'Lara' SELECT Names FROM Cricket where Names like
DECLARE @TotalQuestions int; DECLARE @CorrectQuestions int; DECLARE @IncorrectQuestions int; SELECT ( SET CorrectQuestion =
declare @customerID int set @customerID=1 ;with cteDates as ( select dateadd(hh, datediff(hh, 0, getdate()),
Declare @count nvarchar(max) set @count ='select COUNT(*) from '+ @tablename+'' if( @count =0 )
DECLARE vote_id INT; select id from votes where votes.question_id = question_id and vote_type_id =
declare @node int = 9044; DECLARE @sqlCommand NVARCHAR(MAX) = ( 'SELECT * FROM [@node].[database_name].dbo.table_name'
DECLARE @SQL1 VARCHAR(MAX) SET @SQL1='SELECT * FROM tblResponsibleEngineer WHERE ResponsibleEngineer='+CAST(@ResponsibleEngineer AS VARCHAR(500))+'' EXEC(@SQL1) IF

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.