-
-
Save briangithex/dcda51bec4ccd54244eefa6fc7c20679 to your computer and use it in GitHub Desktop.
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
| declare @Result Table(StationName VarChar(50)) | |
| declare @Position VarChar(50) = 'A' | |
| while(@Position is not null) | |
| BEGIN | |
| insert into @Result values(@Position) | |
| declare @Override varchar(50) = (select top 1 StationToName from StationRoutingOverride where StationFromName = @position) | |
| declare @Failover varchar(50) = | |
| (select top 1 S2.StationName from Stations S1 | |
| join Stations S2 on S2.StationPhysicalOrder = S1.StationPhysicalOrder+1 | |
| where S1.StationName = @Position) | |
| set @Position = coalesce(@Override,@Failover) | |
| END | |
| select * from @Result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment