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.
50 lines
2.0 KiB
50 lines
2.0 KiB
USE [Vertragsverwaltung_20160404]
|
|
GO
|
|
/****** Object: UserDefinedFunction [dbo].[fnkt_get_KPI_hierarchie] Script Date: 02.12.2016 09:08:53 ******/
|
|
DROP FUNCTION [dbo].[fnkt_get_KPI_hierarchie]
|
|
GO
|
|
/****** Object: UserDefinedFunction [dbo].[fnkt_get_KPI_hierarchie] 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 Function [dbo].[fnkt_get_KPI_hierarchie]
|
|
(
|
|
@startkey int
|
|
)
|
|
RETURNS @tmp1 TABLE
|
|
(
|
|
ID INT
|
|
)
|
|
AS
|
|
begin
|
|
|
|
WITH tmp1 (id)
|
|
AS
|
|
(
|
|
SELECT oenr
|
|
FROM oe
|
|
WHERE oenr=@startkey
|
|
UNION ALL
|
|
SELECT C.oenr FROM oe C
|
|
INNER JOIN tmp1 R ON C.parentid = R.id
|
|
)
|
|
INSERT INTO @tmp1
|
|
SELECT id
|
|
FROM tmp1
|
|
|
|
RETURN
|
|
|
|
|
|
end
|
|
|
|
|
|
GO
|