日期:2014-05-18 浏览次数:20534 次
ALTER PROC [dbo].[Getlist] @RecNum varchar(10)='', @UserName varchar(10)='', @StartNum varchar(10)='', @endNum varchar(10)='', @Order varchar(10)='', @return varchar(255)='' output AS declare @endSqlStr varchar(255) declare @SQL varchar(255) declare @selectForm varchar(255) declare @W_YiQi varchar(255) declare @orderby varchar(6) set @selectForm=N'select * from RegInfo' if(@Order='') begin set @orderby=N' id ' end else begin set @orderby= N' RegTime ' end if (@RecNum!='') begin set @W_YiQi=' AND recNum in ( '+@RecNum+' ) ' end else begin set @W_YiQi='' end if (@StartNum!='' and @endNum!='') begin set @W_YiQi=' AND recNum >='+@StartNum+' AND recNum<= '+@endNum end if (@UserName='') begin set @endSqlStr=@selectForm+ ' WHERE id>0 '+@W_YiQi +' order by '+@orderby END ELSE BEGIN set @endSqlStr=@selectForm+ ' WHERE UserName='''+@UserName+''' '+@W_YiQi +' order by '+@orderby END set @return =@endSqlStr
USE [regInfoData] GO DECLARE @return_value int, @return varchar(255) EXEC @return_value = [dbo].[Getlist] @RecNum = N'65535',@Order= N'1', @return = @return OUTPUT SELECT @return as N'@return' SELECT 'Return Value' = @return_value GO