验证中...
Languages: SQL
Categories: 数据库相关
Latest update 2019-05-21 10:13
gistfile1.txt
Raw Copy
ALTER FUNCTION [dbo].[F_FIND_CHILDREN_DEPART] (@ID VARCHAR(20))
RETURNS @TMPTALBE TABLE(ID VARCHAR(20),LEVEL INT)
AS
BEGIN
DECLARE @LEVEL int
SET @LEVEL = 1
INSERT INTO @TMPTALBE SELECT @ID , @LEVEL
WHILE @@ROWCOUNT > 0
BEGIN
SET @LEVEL = @LEVEL+1
INSERT INTO @TMPTALBE SELECT A.DEPART_ID,@LEVEL
FROM TPRG_DEPART AS A, @TMPTALBE AS B
WHERE A.PARENT_DEPART_ID = B.ID and B.level = @LEVEL - 1
END
RETURN
END

Comment list( 0 )

You need to Sign in for post a comment

Help Search

Gitee_you_jiang_zheng_wen Zheng_wen_close