prueba con algo como esto:
Código SQL:
Ver originalDECLARE @query Nvarchar(MAX)
SET @query=
'SELECT RXFAM1, RXFAM2, RXFAM3, PSPREC, VMVNNM
FROM
(SELECT RXFAM1, RXFAM2, RXFAM3, PSPREC, VMVNNM, ROW_NUMBER()
OVER
(ORDER BY'
-- Orden x marca
IF @marc='ok'
SET @query=@query + 'VMVNNM)'
IF @prc='desc'
SET @query=query + 'PSPREC)'
IF @prc='asc'
SET @query=query + 'PSPREC)'
SET @query=@query + ' AS Recursos
FROM dbo.Recursos WHERE CPA01 LIKE ''%'' + @palabra + ''%'')
AS Resultados
WHERE Recursos BETWEEN 8 * @PageNumber + 1 AND 8 * (@PageNumber + 1)'
saludos!