You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
5.8 KiB
68 lines
5.8 KiB
USE [Vertragsverwaltung_20160404]
|
|
GO
|
|
/****** Object: StoredProcedure [dbo].[sp_ServerInventar_sik] Script Date: 02.12.2016 09:08:53 ******/
|
|
DROP PROCEDURE [dbo].[sp_ServerInventar_sik]
|
|
GO
|
|
/****** Object: StoredProcedure [dbo].[sp_ServerInventar_sik] Script Date: 02.12.2016 09:08:55 ******/
|
|
SET ANSI_NULLS ON
|
|
GO
|
|
SET QUOTED_IDENTIFIER ON
|
|
GO
|
|
|
|
|
|
-- =============================================
|
|
-- Author: <Author,,Name>
|
|
-- Create date: <Create Date,,>
|
|
-- Description: <Description,,>
|
|
-- =============================================
|
|
CREATE PROCEDURE [dbo].[sp_ServerInventar_sik]
|
|
@fnkt INT=0
|
|
AS
|
|
BEGIN
|
|
DECLARE @tbl TABLE(
|
|
Mainkey INTEGER,
|
|
Parentid INTEGER,
|
|
bezeichnung VARCHAR(255),
|
|
imageindex integer)
|
|
|
|
--Root
|
|
INSERT @tbl ( Mainkey, Parentid, bezeichnung, imageindex ) VALUES ( 0,NULL, 'Root',1)
|
|
|
|
--Umgebung
|
|
INSERT @tbl ( Mainkey, Parentid, bezeichnung, imageindex )
|
|
SELECT DISTINCT dbo.Server_Umgebung.Server_UmgebungNr*100000 AS MainKey, 0 AS Parentid, dbo.Server_Umgebung.Bezeichnung, 0 AS ImageIndex
|
|
FROM dbo.Server_Inventar INNER JOIN
|
|
dbo.Server_Umgebung ON dbo.Server_Inventar.Server_UmgebungNr = dbo.Server_Umgebung.Server_UmgebungNr WHERE server_inventar.Aktiv=1 ORDER BY MainKey
|
|
|
|
|
|
-- Server-Kategorie
|
|
INSERT @tbl ( Mainkey, Parentid, bezeichnung, imageindex )
|
|
SELECT DISTINCT
|
|
dbo.Server_Kategorie.Server_KategorieNr * 110000 + dbo.Server_Inventar.Server_UmgebungNr AS MainKey, dbo.Server_Inventar.Server_UmgebungNr * 100000 AS ParentID, dbo.Server_Kategorie.Bezeichnung,
|
|
1 AS ImageIndex
|
|
FROM dbo.Server_Inventar INNER JOIN
|
|
dbo.Server_Kategorie ON dbo.Server_Inventar.Server_KategorieNr = dbo.Server_Kategorie.Server_KategorieNr
|
|
WHERE server_inventar.aktiv=1
|
|
|
|
-- Server
|
|
INSERT @tbl ( Mainkey, Parentid, bezeichnung, imageindex )
|
|
SELECT DISTINCT ServerInventarNr AS MainKey, Server_KategorieNr * 110000 + Server_UmgebungNr AS ParentID, Bezeichnung, 2 AS ImageIndex
|
|
FROM dbo.Server_Inventar
|
|
WHERE (Aktiv = 1)
|
|
ORDER BY Bezeichnung
|
|
|
|
--IF @fnkt=0 BEGIN -- Nach Umgebung
|
|
-- INSERT @tbl(Mainkey,parentid,bezeichnung,imageindex) SELECT Server_Umgebungnr*100000,0,server_umgebung.Bezeichnung,1 FROM dbo.Server_Umgebung WHERE aktiv=1
|
|
-- INSERT @tbl(mainkey,Parentid,bezeichnung,imageindex) SELECT dbo.Server_Inventar.ServerInventarNr,dbo.Server_Inventar.Server_UmgebungNr*10000,bezeichnung,1 FROM dbo.Server_Inventar
|
|
-- END
|
|
--UPDATE @tbl SET imageindex=0 WHERE mainkey > 9999
|
|
SELECT * FROM @tbl
|
|
|
|
|
|
|
|
END
|
|
|
|
|
|
|
|
GO
|