declare @n nvarchar(4000) set @n = '' select @n = @n + wzdm + '/' from t_wz
select stuff((select '/'+wzdm from t_wz for xml path('')),1,1,'')
if object_id('[t_wz]') is not null drop table [t_wz] go create table [t_wz] (wzdm nvarchar(4)) insert into [t_wz] select '01' union all select '02' union all select '03' union all select 'aa' union all select 'bb' select distinct [values]=stuff((select '/'+wzdm from t_wz t for xml path('')), 1, 1, '') from t_wz --01/02/03/aa/bb
set @n = ''
select @n = @n + wzdm + '/'
from t_wz
go
create table [t_wz] (wzdm nvarchar(4))
insert into [t_wz]
select '01' union all
select '02' union all
select '03' union all
select 'aa' union all
select 'bb'
select distinct [values]=stuff((select '/'+wzdm from t_wz t for xml path('')), 1, 1, '')
from t_wz
--01/02/03/aa/bb
declare @n nvarchar(4000)
set @n = ''
select @n = @n + wzdm + '/'
from t_wz
select @n
2000 用函数,或者是1楼的语句就OKdeclare @n nvarchar(4000)
set @n = ''
select @n = @n + wzdm + '/'
from t_wz
select @n