但如果你想放在一个表里也可以这样
declare @str varchar(200)
set @str='伊拉克,奥运会,中国,CSDN专家门诊'
Select Top 1000 ID = Identity(Int, 1, 1) Into #T From Syscolumns A, Syscolumns B
--Insert table1
Select '1', Substring(@str, B.ID, CharIndex(',', @str+ ',', B.ID) - B.ID)
From #T B
Where Substring(',' + @str, B.id, 1) = ','
Drop Table #T
或
declare @str varchar(200)
set @str='伊拉克,奥运会,中国,CSDN专家门诊'
select @str='select '''+replace(@str,',',''' as st union all select ''')+''''
declare @str varchar(100)
declare @tmpstr varchar(100)
declare @i int
declare @sql varchar(1000)
set @sql=''
set @str='别克,奥运会,中国,CSDN专家门诊'
while charindex(',',@str)>0
begin
set @i= charindex(',',@str)
if @i>0
begin
if @sql=''
begin
set @sql=@sql+'title like ''%'+substring(@str,1,@i-1)+'%'' '
end else
begin
set @sql=@sql+'or title like ''%'+substring(@str,1,@i-1)+'%'' '
end
set @str=substring(@str,@i+1,len(@str)-@i)
end
end
if @str<>''
begin
if @sql=''
begin
set @sql=@sql+'title like ''%'+@str+'%'' '
end else
begin
set @sql=@sql+'or title like ''%'+@str+'%'' '
end
end
select @sql = 'select top 20 * from news where '+ @sql +'order by id desc'
exec(@sql)