请教各位大神,这个存储过程为什么返回两个结果集?非常感谢
ALTER procedure [dbo].[Sp_QueryFeeInfo]
@feedict varchar(100),
@idnum varchar(20)
as
begin
SET NOCOUNT ON;
declare @sql nvarchar(4000)
declare @ParameterDefinition nvarchar(4000);
select @ParameterDefinition='@nameParameter varchar(100),@idnumParameter varchar(20)';
select @sql=N'select * from charges where 1=1'
if @feedict is not null
select @sql+=@sql+N' and feedict=@nameParameter';
if @idnum is not null
select @sql+=@sql+N' and idnum=@idnumParameter';
exec sp_executeSQL @sql,@ParameterDefinition,@nameParameter=@feedict,@idnumParameter=@idnum;
end
------解决方案--------------------你的代码好像有问题,改成这样试试:
ALTER procedure [dbo].[Sp_QueryFeeInfo]
@feedict varchar(100),
@idnum varchar(20)
as
begin
--SET NOCOUNT ON;
declare @sql nvarchar(4000)
declare @ParameterDefinition nvarchar(4000);
select @ParameterDefinition='@nameParameter varchar(100),@idnumParameter varchar(20)';
select @sql=N'select * from charges where 1=1'
if @feedict is not null
select @sql=@sql+N' and feedict=@nameParameter';
if @idnum is not null
select @sql=@sql+N' and idnum=@idnumParameter';
exec sp_executeSQL @sql,@ParameterDefinition,@nameParameter=@feedict,@idnumParameter=@idnum;
end