用字符串处理函数,结合distinct语句就行了. begin tran--创建数据测试环境 create table tb(abc varchar(10)) insert into tb select 'aaa,bbb,ss' union all select 'aaa' union all select 'wwww,kjl' union all select 'fsfff' union all select 'wwww' union all select 'ff,ff'--得到结果 select distinct case charindex(',',abc) when 0 then abc else left(abc,charindex(',',abc)-1) end as abc from tbrollback tran
select distinct case when charindex(',',ABC)=0 then ABC else left(ABC,charindex(',',ABC)-1) end from tableName
begin tran--创建数据测试环境
create table tb(abc varchar(10))
insert into tb
select 'aaa,bbb,ss'
union all select 'aaa'
union all select 'wwww,kjl'
union all select 'fsfff'
union all select 'wwww'
union all select 'ff,ff'--得到结果
select distinct case charindex(',',abc) when 0 then abc
else left(abc,charindex(',',abc)-1) end as abc
from tbrollback tran