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
Β
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