sql server sp_executesql动态sql
declare @count_sql nvarchar(max),@count int set @count_sql = 'select @vlaue = count(1) from t_dd_qm_product_testitem_course with (nolock) where group_number in ('+@group_number_str+')'; exec sp_executesql @count_sql,N'@vlaue int output',@count output print @count