

/***************************************
* STORED stp_prtCartMatPrimaByUDC
*
* ottiene il record del Cartellino Materia Prima dato l'UDC richiesto x la stampa
*
****************************************/
CREATE PROCEDURE [dbo].[stp_prtCartMatPrimaByUDC]
(
      @UDC VARCHAR(50)
)
AS
SELECT
        RQ.nRapQual,
        RQ.DataRapQual,
        RQ.ProgUDC,
        RQ.CodFor,
        RQ.DestTerz,
        ec.Particolare AS CodLega,
        RQ.DataPrelFus,
        RQ.TurnoPrelFus,
        ec.Qta,
        RQ.DestLega,
        RQ.LegaScaric,
        RQ.BenesQual,
        ec.UDC,
        Fo.DescFornitore,
        Fo.DescFornitore2,
        Le.CodLega AS CodLega2,
        Le.DescLega,
        Le.DescLega2,
        ISNULL(ec.Note,'') AS Note
FROM ElencoCartellini ec
LEFT JOIN RilPro.RapQual AS RQ
  ON ec.UDC = RQ.UDC
LEFT JOIN RilPro.AnagFornitori AS Fo
  ON RQ.CodFor = Fo.CodFornitore
LEFT JOIN RilPro.AnagLeghe Le
  ON RQ.CodLega = 'L' + Le.CodLega
WHERE ec.UDC = RTRIM(@UDC)                  -- 'UB31000000001'

RETURN


