Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
http://postimg.org/image/8fm4y89w9/[^]

here is the image , i want to sort in SP ,where i am going wrong?


SQL
USE [Game_test]
GO
/****** Object:  StoredProcedure [dbo].[GetCustomersPageWise]    Script Date: 11/15/2013 23:46:35 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
ALTER  PROCEDURE [dbo].[GetCustomersPageWise]
      @PageIndex INT = 1
      ,@PageSize INT = 10
      ,@OrderBy varchar(15)
      ,@RecordCount INT OUTPUT
AS
BEGIN
      SET NOCOUNT ON;
      SELECT ROW_NUMBER() OVER
      (
            ORDER BY @OrderBy  ASC
      )AS RowNumber
      ,[Playerid]
      ,[playername]
      ,[designation]
     INTO #Results
      FROM [player]
     
      SELECT @RecordCount = COUNT(*)
      FROM #Results
           
      SELECT * FROM #Results
      WHERE RowNumber BETWEEN(@PageIndex -1) * @PageSize + 1 AND(((@PageIndex -1) * @PageSize + 1) + @PageSize) - 1
     
      DROP TABLE #Results
END
Posted
Comments
ZurdoDev 15-Nov-13 16:07pm    
What is happening?
RedDk 15-Nov-13 21:47pm    
Just a question. About design. The user is able to define a variable in the hopes of naming a column of data on which a SORT will be done? Start there.

And also, links to images, here in Q&A, go unnoticed. Explain the problem, show the code you use, the exact error if that is the case, and throw in some data if it will uncomplicate things.

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