I am having trouble with this one. I am trying to do pagination (JQGrid) and am dynamically created a sql statement to be executed. Right now, I am getting an error message:
Msg 245, Level 16, State 1, Procedure pEreq_Get_RequestSummaryByUID, Line 52
Conversion failed when converting the varchar value 'SELECT TOP ' to data type int.
Here is my SQL:
@LIMIT, @START and @END are all INT.
Any help would be greatly appreciated, this works without pagination and this is the last step toward using JQGrid with classic ASP and ajax.
Msg 245, Level 16, State 1, Procedure pEreq_Get_RequestSummaryByUID, Line 52
Conversion failed when converting the varchar value 'SELECT TOP ' to data type int.
Here is my SQL:
@LIMIT, @START and @END are all INT.
Any help would be greatly appreciated, this works without pagination and this is the last step toward using JQGrid with classic ASP and ajax.
Code:
SET @SQL = 'SELECT TOP ' + @LIMIT + ' FROM
(SELECT row_number() OVER (ORDER by ereq) as resultNum, r.ereq AS Ereq,
r.CreatorFirstName + '' '' + r.CreatorLastName AS Creator,
r.ChargeDepartment AS Dept,
COALESCE(r.ChargeEOC,NULL,0) AS ChargeEOC,
r.RequestType AS [Type],
COALESCE(r.RequestCost,NULL,0.00) AS RequestCost
FROM dbo.Request r
INNER JOIN dbo.[Status] s ON s.ereq = r.ereq
WHERE s.[Status] = ''Created'' AND r.creator = ''' + @UID + '''
ORDER BY ' + @SIDX + ' ' + @SORD + ') AS numberResults
WHERE resultnum BETWEEN ' + @START + ' AND ' + @END