SQL SERVER 存储过程
程序代码:
DECLARE @sql VARCHAR(1000) SET @sql='SELECT Item_id as '+'周数' select @sql=@sql+ ',max(case [sd] when '''+sd+''' then jhccl else 0 end)['+sd+']' from(select distinct sd from MRP_Plan where sd<>'当前') as a SET @sql=@sql+'from MRP_Plan WHERE Item_id in (select distinct Item_id from MRP_Plan where Item_id in (select Item_id from Production where work_cen_name=''中心1''))and MRP_ID=''MR002'' group by Item_id ' exec(@sql)有没有办法把上面的代码改成通用的存储过程 work_cen_name和MRP_id作为输入参数?