Using SQL Server, how do I split a string so I can access item x?
Take a string "Hello John Smith". How can I split the string by space and access the item at index 1 which should return "John"?
Using SQL Server, how do I split a string so I can access item x?
Take a string "Hello John Smith". How can I split the string by space and access the item at index 1 which should return "John"?
The following example uses a recursive CTE
Update 18.09.2013
Demo on SQLFiddle
Here I post a simple way of solution
Execute the function like this
I know its late, but I recently had this requirement and came up with the below code. I don't have a choice to use User defined function. Hope this helps.