@strwhere varchar(1500) = '' -- 查询条件 (注意: 不要加 where)
as
declare @strsql varchar(5000) -- 主语句
declare @strtmp varchar(110) -- 临时变量
declare @strorder varchar(400) -- 排序类型
if @docount != 0
begin
if @strwhere !=''
set @strsql = "select count(*) as total from [" + @tblname + "] where "+@strwhere