USE [Vertragsverwaltung_20160404] GO /****** Object: StoredProcedure [dbo].[sp_applikation_get_vertragselemente] Script Date: 02.12.2016 09:08:54 ******/ DROP PROCEDURE [dbo].[sp_applikation_get_vertragselemente] GO /****** Object: StoredProcedure [dbo].[sp_applikation_get_vertragselemente] Script Date: 02.12.2016 09:08:55 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: Stefan Hutter -- Create date: 21.01.2009 -- Description: Gibt die Lizenzvertragselemente einer Applikation zurück -- ============================================= CREATE PROCEDURE [dbo].[sp_applikation_get_vertragselemente] @applikationnr int, @mitarbeiternr int as SET NOCOUNT ON; SELECT DISTINCT dbo.Applikation.ApplikationNr, dbo.Vertragselement.Vertragselementnr, dbo.Vertragstyp.Vertragstyp, dbo.Vertragselement.Bezeichnung + ' / ' + dbo.Vertragspartner.NameZ1 + ', ' + dbo.Vertragspartner.Ort AS Vertragselement, dbo.Vertragselement.Aktiv, dbo.Vertragselement.Erstellt_am, dbo.Vertragselement.Mutiert_am, dbo.Vertragselement.Mutierer, dbo.Vertragselement.SecurityLevelNr, dbo.VertragselementApplikation.Vertragselementapplikationnr, dbo.VertragselementApplikation.ApplikationVersionNr, dbo.ApplikationVersion.Version --dbo.Lizenzkauf.LizenzkaufNr FROM dbo.Vertragspartner INNER JOIN dbo.Applikation INNER JOIN dbo.Vertragstyp INNER JOIN dbo.Vertragselement ON dbo.Vertragstyp.Vertragstypnr = dbo.Vertragselement.VertragstypNr INNER JOIN dbo.VertragselementApplikation ON dbo.Vertragselement.Vertragselementnr = dbo.VertragselementApplikation.Vertragselementnr ON dbo.Applikation.ApplikationNr = dbo.VertragselementApplikation.Applikationnr ON dbo.Vertragspartner.VertragspartnerNr = dbo.Vertragselement.VertragspartnerNr LEFT OUTER JOIN dbo.Lizenzkauf ON dbo.VertragselementApplikation.VertragselementApplikationnr = dbo.Lizenzkauf.Vertragselementapplikationnr LEFT OUTER JOIN dbo.ApplikationVersion ON dbo.VertragselementApplikation.ApplikationVersionNr = dbo.ApplikationVersion.ApplikationVersionNr WHERE (dbo.Vertragselement.SecurityLevelNr in (select SecurityLevelNr from dbo.Get_SecurityLevelTab(@mitarbeiternr))) AND (dbo.vertragselementapplikation.Applikationnr = @applikationnr) AND (dbo.VertragselementApplikation.Aktiv = 1) AND (dbo.Lizenzkauf.Aktiv = 1) --SELECT DISTINCT -- dbo.Applikation.ApplikationNr, dbo.Vertragselement.Vertragselementnr, dbo.Vertragstyp.Vertragstyp, -- dbo.Vertragselement.Bezeichnung + ' / ' + dbo.Vertragspartner.NameZ1 + ', ' + dbo.Vertragspartner.Ort AS Vertragselement, dbo.Vertragselement.Aktiv, -- dbo.Vertragselement.Erstellt_am, dbo.Vertragselement.Mutiert_am, dbo.Vertragselement.Mutierer, dbo.Vertragselement.SecurityLevelNr, -- dbo.VertragselementApplikation.Vertragselementnr AS Expr1, dbo.VertragselementApplikation.ApplikationVersionNr, dbo.ApplikationVersion.Version --FROM dbo.Vertragstyp INNER JOIN -- dbo.Vertragselement ON dbo.Vertragstyp.Vertragstypnr = dbo.Vertragselement.VertragstypNr INNER JOIN -- dbo.VertragselementApplikation ON dbo.Vertragselement.Vertragselementnr = dbo.VertragselementApplikation.Vertragselementnr INNER JOIN -- dbo.Applikation INNER JOIN -- dbo.Lizenzkauf ON dbo.Applikation.ApplikationNr = dbo.Lizenzkauf.ApplikationNr ON dbo.VertragselementApplikation.Applikationnr = dbo.Applikation.ApplikationNr AND -- dbo.VertragselementApplikation.Vertragselementnr = dbo.Lizenzkauf.Vertragselementnr INNER JOIN -- dbo.Vertragspartner ON dbo.Vertragselement.VertragspartnerNr = dbo.Vertragspartner.VertragspartnerNr LEFT OUTER JOIN -- dbo.ApplikationVersion ON dbo.VertragselementApplikation.ApplikationVersionNr = dbo.ApplikationVersion.ApplikationVersionNr --WHERE (dbo.Vertragselement.SecurityLevelNr <= dbo.Get_SecurityLevel(1)) AND (dbo.Lizenzkauf.ApplikationNr = @applikationnr) AND (dbo.VertragselementApplikation.Aktiv = @mitarbeiternr) AND -- (dbo.Lizenzkauf.Aktiv = 1) --SELECT dbo.Applikation.ApplikationNr, dbo.Vertragselement.Vertragselementnr, dbo.Vertragstyp.Vertragstyp, dbo.Lizenztyp.Bezeichnung AS Lizenztyp, -- dbo.Vertragselement.Bezeichnung AS Vertragselement, dbo.Vertragselement.Aktiv, dbo.Vertragselement.Erstellt_am, dbo.Vertragselement.Mutiert_am, -- dbo.Vertragselement.Mutierer, dbo.Vertragselement.SecurityLevelNr --FROM dbo.Vertragselement INNER JOIN -- dbo.Applikation ON dbo.Vertragselement.ApplikationNr = dbo.Applikation.ApplikationNr INNER JOIN -- dbo.Lizenztyp ON dbo.Vertragselement.Lizenztypnr = dbo.Lizenztyp.Lizenztypnr INNER JOIN -- dbo.Vertragstyp ON dbo.Vertragselement.VertragstypNr = dbo.Vertragstyp.Vertragstypnr --where dbo.vertragselement.applikationnr=@applikationnr and dbo.vertragselement.securitylevelnr in (select SecurityLevelNr from dbo.Get_SecurityLevelTab(@mitarbeiternr)) GO