/****************************************
* STORED stp_ParticolariDistinctByAlSourceDest
*
* elenco dei particolari dati 2 AL per union e distinct
*
* Steamware, S.E.L.
* mod: 2014.03.13
*
****************************************/
CREATE PROCEDURE stp_ParticolariDistinctByAlSourceDest
(
	@AL_source	VARCHAR(50),
	@AL_dest	VARCHAR(50)
)
AS

SELECT DISTINCT ap.*
FROM AL2UDC a2u
INNER JOIN ElencoCartellini ec
	ON a2u.UDC = ec.UDC
INNER JOIN RilPro.AnagParticolari ap
	ON ec.Particolare = ap.Particolare
WHERE a2u.AL IN (
		@AL_source
		, @AL_dest
		)

RETURN