问题描述
部分出错的存储过程ALTERPROCEDUREdbo.fenye@pagesizeint(4)ASdeclare@unumintset@unum=@pagesize*5if@pagesize>0beginselecttop5*fromwupinwhereidnotin(selecttop@unumidfromwupinorderbyid)//有错误的行end这部分是出错的地方。提示@unum附近有错。
解决方案
解决方案二:
id改为[id]
解决方案三:
CREATEPROCEDUREUP_GetRecordByPage@tblNamevarchar(255),--表名@fldNamevarchar(255),--主键字段名@PageSizeint=10,--页尺寸@PageIndexint=1,--页码@IsReCountbit=0,--返回记录总数,非0值则返回@OrderTypebit=0,--设置排序类型,非0值则降序@strWherevarchar(1000)=''--查询条件(注意:不要加where)ASdeclare@strSQLvarchar(6000)--主语句declare@strTmpvarchar(100)--临时变量declare@strOrdervarchar(400)--排序类型if@OrderType!=0beginset@strTmp='<(selectmin'set@strOrder='orderby['+@fldName+']desc'endelsebeginset@strTmp='>(selectmax'set@strOrder='orderby['+@fldName+']asc'endset@strSQL='selecttop'+str(@PageSize)+'*from['+@tblName+']where['+@fldName+']'+@strTmp+'(['+@fldName+'])from(selecttop'+str((@PageIndex-1)*@PageSize)+'['+@fldName+']from['+@tblName+']'+@strOrder+')astblTmp)'+@strOrderif@strWhere!=''set@strSQL='selecttop'+str(@PageSize)+'*from['+@tblName+']where['+@fldName+']'+@strTmp+'(['+@fldName+'])from(selecttop'+str((@PageIndex-1)*@PageSize)+'['+@fldName+']from['+@tblName+']where'+@strWhere+''+@strOrder+')astblTmp)and'+@strWhere+''+@strOrderif@PageIndex=1beginset@strTmp=''if@strWhere!=''set@strTmp='where'+@strWhereset@strSQL='selecttop'+str(@PageSize)+'*from['+@tblName+']'+@strTmp+''+@strOrderendif@IsReCount!=0set@strSQL='selectcount(*)asTotalfrom['+@tblName+']'+'where'+@strWhereexec(@strSQL)GO
解决方案四:
@pagesizeintselecttop@unumidfromwupinorderbyid这句为什么会在@unum里出错?