Tree

xiaoxiao2021-03-05  19

Create Procedure Pro_Menu Asselect a. * From Tablename a Join F_ID () B on A.ID = B.Idorder by B.SIDGOCREATE FUNCTION F_ID () Returns @re Table (ID INT, SID VARCHAR (8000)) ASBEGIN - for numbers Normal, need unified encoding width declare @Idlen int, @ IDHeader varchar (20) select @ idlen = max (len (id)), @ idheader = space (@Idlen) from TableName

Declare @l int set @ @ = 0 INSERT INTO @RE SELECT ID, RIGHT (@ iDHeader Cast (ID AS VARCHAR), @ idlen) from TBL_MENU where i_depth = @ l While @@ Rowcount> 0 Begin Set @ L = @ L 1 INSERT INTO @RE SELECT A.ID, B.SID ',' Right (@ IDHeader Cast (A.ID As Varchar), @ idlen) from tablename a join @re b on A.PID = B. ID and A.I_Depth=@l End Returnend

Add a depth I_DEPTH

转载请注明原文地址:https://www.9cbs.com/read-36499.html

New Post(0)