Split in MS SQL SERVER

Here I shall describe about split in MS SQL.

There is no built in function for splitting your text, that’s why I am describing two customize function for performing split operation in MS SQL.


Split function 1: This function returns table that’s why we can say it table valued function.

--select * from fnSplit('1,22,333,444,,5555,666', ',')
CREATE FUNCTION dbo.fnSplit(
  @sInputList VARCHAR(8000) -- List of delimited items
, @sDelimiter VARCHAR(8000) = ',' -- delimiter that separates items
) RETURNS @List TABLE (item VARCHAR(8000))

 Continue reading