SQL行转列
SELECT p.KeyId,AttName= (STUFF((SELECT TOP 2 ' ' + item.ItemName FROM Pro_PropertyAttributeRelations pat LEFT JOIN Sys_SysParameterItems item
ON pat.PropertyAttributeKeyId=item.KeyId
WHERE pat.PropertyKeyId=p.KeyId ORDER BY NEWID() FOR
XML PATH('')
), 1, 1, '') )
FROM dbo.Pro_Propertys p
INNER JOIN VW_Adm_B_PushPropertys attr ON p.KeyId=attr.KeyId
GROUP BY p.KeyId