declare @str varchar(1000),@strSQL Varchar(2000)
set @str='a,b,c,d'
set @strSQL='select '''+replace(@str,',',''' union all select ''')+''''
print @strSQL
exec(@strSQL)
drop table #temp
select top 1000 identity(int,1,1) as col,0 aa into #temp from
(select top 100 * from sysobjects)a,
(select top 100 * from sysobjects)b,
(select top 100 * from sysobjects)c
declare @a table (id int,string varchar(8000))
insert @a select 1 ,'a,b,c,sd,dfsdfg'
union select 2, 'a,n,sdf,we,t'
union select 3, 's,df,df'
select id,substring(','+string+',',col+1,charindex(',',','+string+',',col+1)-(col+1))
from @a a,#temp b
where len(string+',')-len(replace(string,',',''))>=b.col
order by id