I have a table like this
Value String
-------------------
1 Cleo, Smith
I want to separate the comma delimited string into two colu
This worked for me
CREATE FUNCTION [dbo].[SplitString](
@delimited NVARCHAR(MAX),
@delimiter NVARCHAR(100)
) RETURNS @t TABLE ( val NVARCHAR(MAX))
AS
BEGIN
DECLARE @xml XML
SET @xml = N'' + REPLACE(@delimited,@delimiter,' ') + ' '
INSERT INTO @t(val)
SELECT r.value('.','varchar(MAX)') as item
FROM @xml.nodes('/t') as records(r)
RETURN
END