I got this function from someone on here:
create FUNCTION [dbo].[fnSplitString] (@s varchar(512),@sep char(1))
RETURNS table
AS
RETURN (
WITH Pieces(pn, start, stop) AS (
SELECT 1, 1, CHARINDEX(@sep, @s)
UNION ALL
SELECT pn + 1, stop + 1, CHARINDEX(@sep, @s, stop + 1)
FROM Pieces
WHERE stop > 0
)
SELECT pn,
SUBSTRING(@s, start, CASE WHEN stop > 0 THEN stop-start ELSE 512 END) AS s
FROM Pieces
)
Normally in where clauses of sprocs I call this type of function like this:
WHERE u.[Fleet] IN (SELECT [VALUE] FROM dbo.udf_GenerateVarcharTableFromStringList(@Fleets, ','))
How do I go about calling the above function in a similar manner?
Thanks!