根据表2储存的id字符串,查询表一的名称,并以字符串的格式输出,因为这里guid用的UNIQUEIDENTIFIER类型,所以会有一个字段转换。
// An highlighted block
declare @TableGUID UNIQUEIDENTIFIER
select stuff((
select ','+ TableName from table1 where CHARINDEX(cast(table1GUID as varchar(40)),(select GUIDList from table2 WHERE DiscountPlanGUID=@Table2GUID))>0
for xml path('')),1,1,'') as TableName