create function getstrofindex (@str varchar(8000),@index int =0)
returns varchar(8000)
as
begin
  declare @str_return varchar(8000)
  declare @start int
  declare @next int
  declare @location int
  select @start =1
  select @next =1
  select @location = charindex(',',@str,@start)
  while (@location <>0 and @index > @next )
  begin
    select @start = @location +1
    select @location = charindex(',',@str,@start)
    select @next =@next +1
  end
  if @location =0 select @location =len(@str)+1 
  select @str_return = substring(@str,@start,@location -@start)
  if (@index <> @next ) select @str_return = '' 
  return @str_return
end
go--调用:
select dbo.getstrofindex('asdad,etertertyrt,sdfsfsfsf,kskdlfl',3)