srinivas P

srinivas P

  • NA
  • 168
  • 193.1k

Can i pass more than two column names to split function?

Sep 5 2011 1:16 AM
I have split function,in the following way

create function split (@list varchar(max), @delimiter char(1))
returns
@shards table (value varchar(8000))
with schemabinding
as
begin
 
declare @i int;
 
set @i = 0;
 
while @i <= len(@list)
 
begin
   
declare @n int;
   
set @n = charindex(@delimiter, @list, @i);
   
if 0 = @n
   
begin
       
set @n = len(@list);
   
end
   
insert into @shards (value)
     
values (substring(@list, @i, @n-@i+1));
   
set @i = @n+1;
 
end
 
return;
end

Using above function we can pass only one column name at a time,
But my requirement is to pass more than one column Names to split function.
is it possible?

Any thoughts Help me



Answers (3)