--把查询的结果组织为一串字符(板板鞋,兵乓球,篮球,足球)

drop table a create table a( name varchar(20)) insert into a select '足球' union select '篮球' union select '兵乓球' union select '板板鞋' go

DECLARE @combinedString VARCHAR(MAX) SELECT @combinedString = COALESCE(@combinedString + ',','') + Name FROM a select  @combinedString

05-07 15:13