FN_Split() Table Valued Function
Fn_Split()
The link above is to a file with a table-valued function called fn_split(). This function allows you to pass a string of values to an IN clause of a SQL query. It breaks them down into a set of rows in a virtual table. Then you use a subquery in the IN clause.
This function is very useful when passing multi-valued parameters in a SQL Server Reporting Services report into a stored procedure. The parameter is defined in the stored procedure as a large varchar string (max 8000 character). In the stored procedure you would reference the function in the WHERE clause where you want to use the multiple parameter values.
Example:
SELECT *
FROM table
WHERE column IN (SELECT [value] FROM dbo.fn_split(@parameter, ','))
Posted on Friday, December 8, 2006 at 03:45PM
by
Jeff Jones
in Reporting Services, SQL Server 2000, SQL Server 2005
|
Post a Comment

Reader Comments