I am having a stored procedure which gets the comma separated value as an input. I need to separate it and needs to store it in a table as individual rows.
Let the input for SP is :
Rule_ID  ListType_ID  Values
1        2            319,400,521,8465,2013
I need to store it in a table called DistributionRule_x_ListType in the below format:
Rule_ID  ListType_ID  Value
1        2            319
1        2            400
1        2            521
1        2            8465
1        2            2013
My SP looks like below:
ALTER PROCEDURE [dbo].[spInsertDistributionRuleListType]
(@Rule_ID int,
@ListType_ID int,
@Values VARCHAR(MAX)=NULL
)
AS
BEGIN
    INSERT INTO DistributionRule_x_ListType (Rule_ID,ListType_ID,Value)
    VALUES (@Rule_ID,@ListType_ID,@Values)
END
 
     
     
     
     
     
     
     
     
    