Last active
September 8, 2017 13:53
-
-
Save bonskijr/746c639c3c987595f23e67b3b88fcfc2 to your computer and use it in GitHub Desktop.
sample temp table
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT row_number() over (order by (select null)) as RowId, | |
| FileName, | |
| ItemId | |
| INTO #result | |
| FROM cm_steps | |
| DECLARE | |
| @i int, @max int, | |
| @parentId int, | |
| @itemId int; | |
| SELECT @i = MIN(RowId) , @max=MAX(RowId) FROM #result; | |
| WHILE (@i <= @max ) | |
| BEGIN | |
| SET @ItemId = ( SELECT ItemId FROM #result WHERE RowId = @i ); | |
| -- get parentId | |
| SET @parentId = ( SELECT parentId FROM cm_Cases WHERE ItemId = @itemId ) | |
| .. so on and so forth | |
| SET @i = @i+1; | |
| END; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment