日期:2014-05-17 浏览次数:20492 次
ALTER PROCEDURE [dbo].[PRO_Priorflow_get]
@strwhere varchar(500),
......
as
begin
select @total=count(1) from PRO_Priorflow where 1=1 + @strwhere
....
end
时由于前台没有选择no的查询,后台查不到数据,求怎么解决的思路
ALTER PROCEDURE [dbo].[PRO_Priorflow_get]
@strwhere varchar(500),
@begintime varchar(500),
@endtime varchar(500),
@no int
......
as
begin
select @total=count(1) from PRO_Priorflow where 1=1 and time between @begintime and @endtime and NO=@no
....
end
declare @total int, @sqls nvarchar(4000)
set @sqls='select @a=count(*) from tableName where 1=1 and time between'+@begintime+'and'+@endtime+'and no='+@no
exec sp_executesql @sqls,N'@a int output',@total output
select @total
@sql = '.....code......'
exec( @sql )
declare @total int, @sqls nvarchar(4000)
set @sqls='select @a=count(*) from tableName where 1=1 and time between'+@begintime+'and'+@endtime+'and no='+ltrim(@no)
exec sp_executesql @sqls,N'@a int output',@total output
select @total