• Bhuvnesh (3/21/2013)


    Kwisatz78 (3/21/2013)


    My question is, in this case, would that be the best way to code this or would splitting the string first and placing it in a temp table before being queried be better coding practice?

    See this is the general/frequently used approach while dealing with this kind of split string query.

    You query performace will be dependent on how much string(data) will get splitted and join back to another table.

    and above of this , this function will get called for every record.

    It will be per row if it's scalar UDF and called like that:

    SELECT dbo.YourFunction(Col)

    FROM...

    But it will be called once if your UDF returns a table and used in WHERE clause like that:

    SELECT ...

    FROM ...

    WHERE Col IN (SELECT Item FROM dbo.YourSplitFunction(@InputParam))

    Don't forget to use J.Moden splitter (http://www.sqlservercentral.com/articles/Tally+Table/72993/)

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]