Cita:
Iniciado por Libras ya probaste la opcion que te recomende con el query dinamico???
Si pero me da error.
Me dice
Must declare the scalar variable "@RecordCount"
Que son los parametros de entrada y salida
USE [GallitoDigital]
GO
/****** Object: StoredProcedure [dbo].[GetAutosMult] Script Date: 08/10/2011 12:11:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
ALTER PROCEDURE [dbo].[GetAutosMult]
@PageIndex int
,@PageSize int
,@Orden varchar(80)
,@RecordCount int out
,@TipoOrden varchar(80)
,@Marcas varchar(max)
,@TipoOrdenAscDesc varchar(10)
AS
declare @query varchar(max);
BEGIN
SET NOCOUNT ON;
set @query='SELECT Cla.ClaDsc, AviProCod, AviSolWeb, Textos.AviTxt, Avisos.AviCantFot, Avisos.AviCantVis, Avisos.AviVtaCod, Avisos.AviSbpCod, Avisos.AviRec, Avisos.AviDisSup, Avisos.AviDisInf, Avisos.AviOpeNro, Avisos.AviWebFot,Avisos.AviUbiInt4, Avisos.AviUbiInt2, Avisos.AviRecCol, Avisos.AviCabCol, Avisos.AviFonCol, AutMod.AutModDsc, DetAutCero, DetAutMon, DetAutAlar, DetAutBlq, DetAutAirb, DetAutABS, DetAutAire, DetAutAlza, DetAutCil, DetAutColo, DetAutDire, DetAutEstV, DetAutKmt, DetAutAnio, DetAutTran, DetAutTpoA, DetAutImp, ROW_NUMBER() OVER (ORDER BY Avisos.AviUbiInt4 desc, Avisos.AviWebFot desc, Textos.AviTxtOrd
) AS RowNumber
INTO #Results
FROM Avisos INNER JOIN Textos ON Avisos.AviVtaCod = Textos.AviVtaCod INNER JOIN DetAuto ON Avisos.AviVtaCod = DetAuto.DetAutCod INNER JOIN AUTMAR ON DetAuto.DetAutMarC = AUTMAR.AutMarCod AND DetAuto.DetAutTpoC = AUTMAR.AutTpoCod INNER JOIN AUTMOD ON DetAuto.DetAutMarC = AUTMOD.AutMarCod AND DetAuto.DetAutTpoC = AUTMOD.AutTpoCod AND DetAuto.DetAutModC = AUTMOD.AutModCod INNER JOIN AUTTPO ON AUTMOD.AutTpoCod = AUTTPO.AutTpoCod inner join cla on cla.clacod = avisos.aviclacod
Where (Avisos.AviSbpCod <> 3) and (avisos.avisbpcod <> 5) and (' + @Marcas + ')
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'
exec Sp_sqlExec @query
END