22,301
社区成员




declare @strs varchar(500)
set @strs=''
select @strs = @strs +','+name from A12
print @strs
select A12.cc,A12.name,@strs as count from A12
if object_id('[A]') is not null drop table [A]
create table [A] (cc int,name varchar(2),count varchar(20))
insert into [A]
select 1,'AA',null union all
select 2,'BB',null union all
select 3,'CC',null union all
select 4,'DD',null
declare @str varchar(100)
select @str=isnull(@str+',','')+name from [A]
update A set [count]=@str WHERE [COUNT] IS NULL
select * from [A]
--> 测试数据: [A]
if object_id('[A]') is not null drop table [A]
create table [A] (cc int,name varchar(2),count varchar(20))
insert into [A]
select 1,'AA',null union all
select 2,'BB',null union all
select 3,'CC',null union all
select 4,'DD',null
declare @str varchar(100)
select @str=isnull(@str+',','')+name from [A]
update A set [count]=@str
select * from [A]
--> 测试数据: [A]
if object_id('[A]') is not null drop table [A]
create table [A] (cc int,name varchar(2),count varchar(20))
insert into [A]
select 1,'AA',null union all
select 2,'BB',null union all
select 3,'CC',null union all
select 4,'DD',null
declare @t varchar(100)
select @t=isnull(@t+',','')+name from a
update a set [count]=@t
select * from [A]
update a set [count]=[name]
update tb set [count]=name
update a set count=name