Created
September 7, 2018 22:20
-
-
Save iknowkungfoo/c73bccbc43cfadf84e91397e14c97f20 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
/* | |
******* Run on both main and US Soccer databases ******** | |
*/ | |
SET ANSI_NULLS ON | |
GO | |
SET QUOTED_IDENTIFIER ON | |
GO | |
CREATE FUNCTION dbo.integerListToTable ( @strString varchar(max)) | |
RETURNS @Result TABLE(LIST_ID BIGINT) | |
AS | |
/*------------------------------------------------------------------ | |
** Name: [dbo.integerListToTable] | |
** Description : Converts a comma-delimited list of integers to a table. | |
** Example Call : | |
* DECLARE @strString varchar(max); | |
* SET @strString = '1,2,3,4,5'; | |
* select * from dbo.integerListToTable(@strString); | |
* | LIST_ID | | |
* | ------- | | |
* | 1 | | |
* | 2 | | |
* | 3 | | |
* | 4 | | |
* | 5 | | |
******************************************************************** | |
MODIFIED DATE MODIFIED BY DESCRIPTION OF REVISION | |
2018-08-23 Adrian Moreno Creation | |
******************************************************************** | |
------------------------------------------------------------------*/ | |
BEGIN | |
DECLARE @x XML | |
SELECT @x = CAST('<A>'+ REPLACE(@strString,',','</A><A>')+ '</A>' AS XML) | |
INSERT INTO @Result | |
SELECT | |
t.value('.', 'int') AS inVal | |
FROM | |
@x.nodes('/A') AS x(t) | |
RETURN | |
END | |
GO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment