1.将 表 invoiceplandtl 中 ivc_no 组成 ; 分格的字串
invoiceplandtl
id ivc_no
1 a
2 b
3 c
4 a
结果: a;b;c;
语句:
declare @str varchar(2000)
set @str = ''
select @str = @str + Rtrim(ivc_no) + ';' from (select distinct ivc_no from lr_invoiceplandtl)a
select @str as ivc_no