Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

7
  • 2
    Fantastic function. Could do with using nchar() and nvarchar(). Also see below for suggestion with variable-length delimiter. Commented Oct 17, 2009 at 16:47
  • 1
    On SQL Server 2008, this version fails when there are more than 101 items in the list: "The statement terminated. The maximum recursion 100 has been exhausted before statement completion." Commented Feb 12, 2010 at 17:23
  • 1
    @MikeSchenk You can use the OPTION (MAXRECURSION n) hint (msdn.microsoft.com/en-us/library/ms181714.aspx) to change the level of recursion - however, it's not allowed in UDF definitions. This question (social.msdn.microsoft.com/forums/en-US/transactsql/thread/…) would imply that you can specify it outside the UDF and have it still work. Commented Feb 12, 2010 at 18:20
  • 2
    Warning: fails with larger input strings (above about 1000 characters). "The maximum recursion 100 has been exhausted before statement completion." Commented Apr 14, 2010 at 5:39
  • 1
    How can I call this function from a select query? I get the following error: Cannot find either column "dbo" or the user-defined function or aggregate "dbo.fn_Split", or the name is ambiguous. Commented Dec 21, 2012 at 15:36