Created
September 28, 2011 16:39
-
-
Save johnnonolan/1248429 to your computer and use it in GitHub Desktop.
Orded jobs WIP
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
| SET ANSI_NULLS ON | |
| GO | |
| SET QUOTED_IDENTIFIER ON | |
| GO | |
| --aligator => crocodile | |
| ALTer procedure OrderJobs | |
| ( | |
| @jobs varchar(max) | |
| ) | |
| AS | |
| BEGIN | |
| DECLARE @result varchar(max) | |
| DECLARE @CrLf CHAR(2) | |
| SELECT @CrLf = CHAR(13) + CHAR(10); | |
| SELECT @result= '' | |
| IF (CHARINDEX('=>',@jobs) <> -1) | |
| SELECT @result= Substring(@jobs, 1,1) | |
| 'a => '+@CrLf+'b => '+@CrLf+'c => ' | |
| SELECT @result | |
| -- a => c | |
| -- b => | |
| -- c => | |
| END | |
| GO | |
| DECLARE @CrLf CHAR(2) | |
| SELECT @CrLf = CHAR(13) + CHAR(10); | |
| --Step 1 | |
| EXEC dbo.OrderJobs '' | |
| --Step 2 | |
| EXEC dbo.OrderJobs 'b =>' | |
| --Step 3 | |
| declare @input varchar(max) = | |
| 'a => | |
| b => | |
| c =>' | |
| EXEC dbo.OrderJobs @input |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment