Function For Comma separate string to Column in SQL Server

Here is a user defined function that we have created to convert comma separate string values to Table Column,
Mostly we use for IN statement in Select QUERY like

select * from Emp WHERE PKId IN(fn_SplitParameters('1,2,3',','))

CREATE FUNCTION [dbo].[fn_SplitParameters](@String varchar(max), @Delimiter char(1))           
returns @temptable TABLE (ID int,items varchar(max))           
as           
begin           
declare @idx int           
declare @slice varchar(max)           
 declare @ID int           
  set  @ID=0       
select @idx = 1           
if len(@String)<1 or @String is null  return           
           
while @idx!= 0           
begin           
set @idx = charindex(@Delimiter,@String)           
set @ID=@ID+1  
if @idx!=0           
set @slice = left(@String,@idx - 1)           
else           
set @slice = @String     
if(len(@slice)>0)      
insert into @temptable(ID,Items) values(@ID,@slice)           
set @String = right(@String,len(@String) - @idx)           
 if len(@String) = 0 break           
end       
return           
end