-- This file is part of the it-crafts software and is subject to copyright protection.
-- (C) 2024, All rights reserved by Steffen Anders, Elsteraue - Germany
-- Visit also https://www.it-crafts.de.
--

IF 0 < (SELECT count(*) from [sysobjects] where [xtype] = 'P' and [name] = 'itcproc_WartungsAnlagen_perKunde_list')
  DROP PROCEDURE [dbo].[itcproc_WartungsAnlagen_perKunde_list]
GO
CREATE PROCEDURE [dbo].[itcproc_WartungsAnlagen_perKunde_list]
  @Param_Knr varchar(20)
AS
	SELECT 
	    Anl.RecId, Anl.Ident, Anl.Nr, Anl.Bez1, Anl.Bez2, Anl.Monteur
	  , Obj.RecId AS ObjRecId, Obj.Ident AS ObjIdent, Obj.Nr AS ObjNr, Obj.Bez1 AS ObjBez1, Obj.Bez2 AS ObjBez2, Obj.KdNr
	FROM dbo.ut_WartungsObjekte Obj WITH (INDEX(Ik_Key02)) right join dbo.ut_WartungsAnlagen Anl on Obj.Ident = Anl.ObjektId 
	WHERE KdNr = @Param_Knr AND Obj.Nr <> '' 
GO

-- EXECUTE [dbo].[itcproc_WartungsAnlagen_perKunde_list] '10113'
