|
--try
ALTER PROCEDURE dbo.VerseLogPaging
The
@SortColumn as varchar (100) = null,
@StartRow as int = null,
@StopRow as int = null
AS
declare @sql varchar (8000)
---- Create a table variable with an identifier column
set @ sql = '
declare @t_table table
(
[rownum] [int] IDENTITY (1, 1) Primary key NOT NULL,
[SortColumn] [varchar] (40),
[VerseNumber] [varchar] (20),
[SubmitTime] [datetime],
[VerseText] [varchar] (500),
[UserID] [varchar] (20)
)
'
---- Stop processing the query after returning the specified number of @StopRow lines
Set RowCount @StopRow
---- Insert into table variable
set @ sql = @ sql +
'
insert @t_table
(
[VerseNumber], [SubmitTime], [VerseText], [UserID])
SELECT rtrim ([VerseNumber]), [SubmitTime], [VerseText], [UserID]
FROM ConstructionVerseLog
order by ['+ @ SortColumn +'] '
---- Return to the correct result
set @ sql = @ sql +
'SELECT * FROM @t_table WHERE rownum> =' + @StartRow +
'ORDER BY rownum'
EXEC (@sql)
Set RowCount 0-it is better to add this sentence
/ * SET NOCOUNT ON * /
RETURN |
|