title: How to seperate semicolon delimited values from a column in SQL Server and put them in multiple rows?
body: <p>I need to separate a Semicolon Delimited values from a column and put them in different rows. For that I created a function, but I do not know how to map it with the table.</p>
  
  <p>The Function is as follows:</p>
  
  <pre><code>CREATE FUNCTION  [dbo].[String_Split] 
  
  
  
  (
  
  
  @InputString                  VARCHAR(8000),
  
  @Delimiter                    VARCHAR(50)
  
  
  )
  
  RETURNS @Items TABLE 
  
  (
  
  Item                          VARCHAR(8000)
  
  )
  
  AS
  BEGIN
  
        IF @Delimiter = ' '
        BEGIN
              SET @Delimiter = ';'
              SET @InputString = REPLACE(@InputString, ' ', @Delimiter)
        END
  
        IF (@Delimiter IS NULL OR @Delimiter = '')
              SET @Delimiter = ';'
  
        DECLARE @Item           VARCHAR(8000)
        DECLARE @ItemList       VARCHAR(8000)
        DECLARE @DelimIndex     INT
  
        SET @ItemList = @InputString
        SET @DelimIndex = CHARINDEX(@Delimiter, @ItemList, 0)
        WHILE (@DelimIndex != 0)
        BEGIN
              SET @Item = SUBSTRING(@ItemList, 0, @DelimIndex)
              INSERT INTO @Items VALUES (@Item)
  
                         SET @ItemList = SUBSTRING(@ItemList, @DelimIndex+1, LEN(@ItemList)-@DelimIndex)
              SET @DelimIndex = CHARINDEX(@Delimiter, @ItemList, 0)
        END 
  
        IF @Item IS NOT NULL -- At least one delimiter was encountered in @InputString
        BEGIN
              SET @Item = @ItemList
              INSERT INTO @Items VALUES (@Item)
        END
  
        @InputString
        ELSE INSERT INTO @Items VALUES (@InputString)
  
        RETURN
  
  END 
  
  GO
  
  Table Example:
  
  CREATE TABLE dbo.Table
  
  AS
  BEGIN
  
  SELECT a,b,c,d,e,f,g,h,i,j,l,m
  
  FROM Table
  
  END
  
  GO
  </code></pre>
  
  <p><strong>Currently I am using SQL Server 2014 version.</strong> </p>
  
  <p>I am getting the data from different sources and dumped in to the tables in SQL Server. Some of the above columns contain Semicolon separated values lets just say c,e,g columns have Semicolon separated values and I want to separate them and put them in different rows.</p>
  
  <p>I want to achieve this by mapping the Function with the table or the stored procedure that I have already created.</p>
  
  <p>I am stuck in the middle of my project, Can any one please help me with this process?</p>