🌐 US-Proxy
class="wp-singular ssc_script-template-default single single-ssc_script postid-46986 wp-theme-ssc-twentyeighteen aa-prefix-sqlse-" itemscope itemtype="https://schema.org/WebPage" >
Technical Article

Table-valued function FTParsedINT

,

Usage Example:

Β 

IF @createScript = 'Y' AND (@listOfTestId = '' OR @currentId IN (SELECT * FROM dbo.FTParsedINT(@listOfTestId)))
BEGIN

-- script all test case if @listOfTestId is '' or script only the test in the list '1,2' etc.

.

.

.

END

Β 

/****** Object: UserDefinedFunction [dbo].[FTParsedINT] Script Date: 10/04/2007 10:24:16 ******/SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:β€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆMark Drobnis
-- Create date: 10/3/2007
-- Description:β€ˆβ€ˆβ€ˆβ€ˆparse comma seperated list into 
-- a table to use in a in clause
-- =============================================
ALTER FUNCTION [dbo].[FTParsedINT] 
(
β€ˆβ€ˆβ€ˆβ€ˆ-- Add the parameters for the function here
β€ˆβ€ˆβ€ˆβ€ˆ@commaSepList varchar(4000) 
β€ˆβ€ˆβ€ˆβ€ˆ 
)
RETURNS 
@TableList TABLE 
(
β€ˆβ€ˆβ€ˆβ€ˆ-- Add the column definitions for the TABLE variable here
β€ˆβ€ˆβ€ˆβ€ˆId int 
)
AS
BEGIN
β€ˆβ€ˆβ€ˆβ€ˆ-- Fill the table variable with the rows for your result set
β€ˆβ€ˆβ€ˆβ€ˆDECLARE @id AS INT
β€ˆβ€ˆβ€ˆβ€ˆDECLARE @commaFound INT
β€ˆβ€ˆβ€ˆβ€ˆ
β€ˆβ€ˆβ€ˆβ€ˆWHILE @commaSepList <> ''
β€ˆβ€ˆβ€ˆβ€ˆBEGIN
β€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆSET @commaFound = CHARINDEX(',',@commaSepList,0)
β€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆIF @commaFound = 0
β€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆBEGIN
β€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆSET @id = @commaSepList
β€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆSET @commaSepList = ''
β€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆ
β€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆINSERT @TableList
β€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆSELECT @id
β€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆEND
β€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆELSE
β€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆBEGIN
β€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆSET @id = Left(@commaSepList,@commaFound - 1)
β€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆSET @commaSepList = SUBSTRING(@commaSepList,@commaFound + 1,LEN(@commaSepList) - @commaFound)

β€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆINSERT @TableList
β€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆSELECT @id

β€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆEND
β€ˆβ€ˆβ€ˆβ€ˆEND
β€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆβ€ˆ
β€ˆβ€ˆβ€ˆβ€ˆRETURN 
END

Rate

β˜… β˜… β˜… β˜… β˜… β˜… β˜… β˜… β˜… β˜…

(1)

You rated this post out of 5. Change rating

Share

Share

Rate

β˜… β˜… β˜… β˜… β˜… β˜… β˜… β˜… β˜… β˜…

(1)

You rated this post out of 5. Change rating