Filters:

  • Technologies

  • Instructors

  • FN_Split() Table Valued Function by SQL Instructor Jeff Jones

    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, ','))

    You may also like:  Microsoft Second Shot Exams Are On!

    Share your thoughts...

    Please fill out the comment form below to post a reply.