I Want to split the string which contains '1,2,'....which contains in ProgrammId column.. I declared programmid as varchar in stored procedure but in table structure it is declared as int.... So help me i am struck with the query...
while charindex(',',@PROGRAMID) <> 0
DECLARE @var1 nvarchar(30)
begin
select @var1=substring(@PROGRAMID,1,(charindex(',',@PROGRAMID)-1))
INSERT INTO dbo.Table_ProgramJoinDetails(ProgramId ,UserId,programjoindate,programenddate,Slotid)VALUES (@var1 ,@USERID,@slot,@slot1,@Slotid)
SET @PROGRAMID = substring(@PROGRAMID,charindex(',',@PROGRAMID)+1,len(@PROGRAMID))
end