﻿set xact_abort on
go

begin transaction
go

set ANSI_NULLS on
go

/***************************************
* STORED stp_prtCartByUDC
*
* ottiene il record del Cartellino dato l'UDC richiesto x la sstampa
*
* Steamware, S.E.L.
* mod: 2010.05.28
*
****************************************/
alter PROCEDURE stp_prtCartByUDC
(
	@UDC VARCHAR(50)
)
AS
	SELECT
		ElencoCartellini.UDC, ElencoCartellini.CodCS, ISNULL(ElencoCartellini.CodCliente, N'') AS codcliente, 
		ISNULL(ElencoCartellini.RagSociale, N'') AS ragsociale, ISNULL(ElencoCartellini.Particolare, N'') AS particolare,
		ISNULL(ElencoCartellini.DescParticolare, N'') AS DescParticolare, ISNULL(ElencoCartellini.DisegnoGrezzo, N'') AS DisegnoGrezzo, 
		ISNULL(ElencoCartellini.Esponente, N'') AS esponente, ISNULL(ElencoCartellini.CodImpianto, N'') AS CodImpianto,
		ISNULL(ElencoCartellini.DescImpianto, N'') AS DescImpianto, ISNULL(ElencoCartellini.CodStampo, N'') AS codstampo, 
		ISNULL(ElencoCartellini.Figura, N'') AS figura, ISNULL(ElencoCartellini.DataFus, N'') AS datafus,
		ISNULL(ElencoCartellini.TurnoFus, N'') AS turnofus, ISNULL(ElencoCartellini.CodImballo, N'') AS CodImballo, 
		ISNULL(ElencoCartellini.CodSoggetto, N'') AS CodSoggetto, ISNULL(ElencoCartellini.NumCont, N'') AS NumCont,
		ISNULL(ElencoCartellini.Tara, N'') AS tara, ISNULL(ElencoCartellini.Qta, N'') AS qta, ISNULL(ElencoCartellini.CodStato, N'') AS CodStato, 
		ISNULL(ElencoCartellini.IdxPosizione, N'') AS IdxPosizione,
		ISNULL(ElencoCartellini.PesoTot, N'') AS PesoTot, ISNULL(ElencoCartellini.PesoCad, N'') AS PesoCad, ElencoCartellini.CreateDate, 
		ElencoCartellini.ModDate, ISNULL(RilPro.AnagOperatori.Cognome, N'') AS cognome,
		ISNULL(RilPro.AnagOperatori.Nome, N'') AS nome, ISNULL(AnagStatiProdotto.DescStato, N'') AS DescStato, 
		ISNULL(RilPro.AnagImballi.DescImballo, N'') AS DescImballo, RilPro.AnagParticolari.CodFamiglia, RilPro.AnagFamiglie.DescFamiglia 
	FROM
		RilPro.AnagParticolari 
	LEFT OUTER JOIN
		RilPro.AnagFamiglie 
	ON
		RilPro.AnagParticolari.CodFamiglia = RilPro.AnagFamiglie.CodFamiglia 
	RIGHT OUTER JOIN
		ElencoCartellini 
	ON
		RilPro.AnagParticolari.Particolare = ElencoCartellini.Particolare 
	LEFT OUTER JOIN
		AnagStatiProdotto 
	ON
		ElencoCartellini.CodStato = AnagStatiProdotto.CodStato 
	LEFT OUTER JOIN
		RilPro.AnagOperatori 
	ON
		ElencoCartellini.CodSoggetto = RilPro.AnagOperatori.CodSoggetto 
	LEFT OUTER JOIN
		RilPro.AnagImballi 
	ON
		ElencoCartellini.CodImballo = RilPro.AnagImballi.CodImballo 
	WHERE
		(ElencoCartellini.UDC = @UDC)
 

RETURN
go

commit
go



-- registro versione...
INSERT INTO [dbo].[LogUpdateDb] ([Versione],[Data]) VALUES(52, GETDATE())
GO