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
| ALTER PROCEDURE [dbo].[usp_Select_Demande]
(
@strPiece AS NVARCHAR(50),
@strDate AS NVARCHAR(50),
@strIntitule AS NVARCHAR(50),--fournisseur
@strDemandeur AS NVARCHAR(50),
@strImputation AS NVARCHAR(50),--Site
@strEntite AS NVARCHAR(50)='' --Entite
)
AS
BEGIN
-- Insert statements for procedure here
SELECT DISTINCT
top (select top 1 P_Len_Aff from dbo.Parametres)
IsNull(DE.Do_Piece,'') AS Do_Piece,
IsNull(DE.Do_Demandeur,'') AS Do_Demandeur
,IsNull(DE.T_IdContact,'') AS Idcontact,
IsNull(DE.Do_Date,'') AS Do_Date,
IsNull(DE.Do_Projet,'') AS Do_Projet,
IsNull(CT.T_Tier,'') AS T_Tier,
IsNull(CT.T_intitule,'') AS T_intitule,
IsNull(CT.T_Tel,'') AS T_Tel,
IsNull(CT.T_Faxe,'') AS T_Faxe,
IsNull(DE.Do_Imputation,'') AS Do_Imputation,
IsNull(DE.Statut,'') AS Statut
FROM dbo.Compte_Tier AS CT INNER JOIN
dbo.DocEntete AS DE ON CT.T_Tier = DE.T_Tier INNER JOIN
dbo.DocLigne AS DL ON DE.Do_Piece = DL.Do_Piece
WHERE (DE.Do_Piece=@strPiece or @strPiece='')
and(DE.Do_Date=@strDate or @strDate='')
and(CT.T_intitule like '%'+@strIntitule+'%' or @strIntitule='')
and(DE.Do_Demandeur like '%'+@strDemandeur+'%' or @strDemandeur='')
and(DE.Do_Imputation like '%'+@strImputation+'%' or @strImputation='')
and (substring(DE.Do_Piece,13,len(DE.Do_Piece)) like '%'+@strEntite+'%' or @strEntite ='')
order by DE.Do_Piece desc
END |
Partager