declare @parentKey char(36) set @parentKey='B4B519EF-13F9-4F85-A382-21362F337D9D' select [Pro_ProductCategory].[CategoryName]+'('+ cast((select COUNT(1)from Pro_ProductMST where ProductModelKey in (select ModelKey from Pro_ProductModel where CategoryKey=[Pro_ProductCategory].CategoryKey)) as varchar) +')' as 'CategoryStatic' from [Pro_ProductCategory] where [parentKey]=cast(@parentKey as uniqueidentifier)
这里的关键是要写上36这个长度,不然使用varchar是会报错的.