SQL Server Performance

Searching with an Array of values

Discussion in 'SQL Server 2008 General Developer Questions' started by Martin Dixon, Nov 16, 2011.

  1. Martin Dixon New Member


    I have a stored procedure that I want to search an array of values.

    I am passing the following string to the procedure:


    Now in my table I have a column which is an integer, I want to perform a search WHERE column value is in my string.
    So it will bring out all rows with 1254, 2375, 9371 or 4351 in that column.

    How would I do this?

  2. FrankKalis Moderator

    We have a table-valued function that splits the string at the given delimiter and returns a table which we then can use in the main table query. There are lots of examples on the net how to code such a function such as this one: http://blogs.lessthandot.com/index....ming/split-string-in-sql-server-2005-clr-vs-t. Make sure you read through the comments. They contain links to other implementations. Just pick the one you feel most comfortable with.
  3. Martin Dixon New Member

    Sorted it. Cheers ;)

Share This Page