1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[SYN_sp_GetArticlesByDomaine]
-- Add the parameters for the stored procedure here
@domaine_id varchar(5),
@modeleOrder varchar(10),
@numBeginPage int,
@numEndPage int
--@allResult int OUTPUT
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
DECLARE @champ_domaine varchar(5)
DECLARE @champs varchar(2000)
SET @champ_domaine = CASE
WHEN @domaine_id = 'S_01' THEN 'S_01'
WHEN @domaine_id = 'S_02' THEN 'S_02'
WHEN @domaine_id = 'S_03' THEN 'S_03'
WHEN @domaine_id = 'S_04' THEN 'S_04'
WHEN @domaine_id = 'S_05' THEN 'S_05'
END
--
SET @champs = ' S_AUTEUR, S_CAT1, S_CAT2, S_CAT3, S_CAT4, S_CAT5, S_CLE1, S_CLE2, S_CLE3, S_CONDIT_A, S_CONDIT_V, S_CREATION, S_DISPO,
S_DR_AUTEU, S_ID, S_ID_FAMIL, S_ID_RAYON, S_ID_SSFAM, S_IMAGE, S_IMAMIN, S_ISBN, S_MEMOFAC, S_MEMOWEB, S_MODELE, S_MODELEE,
S_MODELEN, S_NBPAGE, S_PARU, S_PRIX_HT, S_PRIX_TI, S_QDISPO, S_QV_3, S_SERIE, S_SOMMEIL, S_SSTITRE, S_STATUT, S_TAUX_TVA,
S_TEXTE, S_WEB, ROW_NUMBER() OVER (ORDER BY ' + @modeleOrder + ') AS RowNumber FROM STOCK WHERE (S_WEB = 1) AND (' + @champ_domaine + ' = 1)'
WITH OrderedArticles AS
(
SELECT @champs
)
SELECT * FROM OrderedArticles WHERE RowNumber BETWEEN @numBeginPage AND @numEndPage
END |
Partager