直接上代码吧,根据不同的条件拼写sql后并执行 ALTER PROCEDURE [dbo].[usp_Statistic_WJB_DZSK_ZT] ( @year int, @half int,--0表示全年,1表示上半年,2下半年 @isAll int --0表示只统计党政干部人员,1表示统计全部 ) as declare @sql nvarchar() set @sql=N'select id from chgrwpj where id in(select distinct parentid…