日期:2014-05-18 浏览次数:20528 次
--些存储过程是通过传入的表名,字段,关键字,查询条件,排序字段来进行查询,返回记录记录总数 drop procedure mytestproceduer go create PROCEDURE mytestproceduer @serchclumname char(8000),--查询的字段列表 @serchwords char(10),--查询的关键字 @serchtable char(20),--查询的表名 @topnumber int=0,--查询顶部的记录条数 @outputnumber int=10 output--返回的记录总数 AS declare @serchtablename char(8000); declare @selectcount3 char(8000); BEGIN select @serchtablename='select top 1 ' + @serchclumname +' from '+ Rtrim(@serchtable) +' where [C_name]='''+rtrim(@serchwords)+'''' +' order BY C_id'; exec (@serchtablename); print @serchtablename; select @selectcount3='select ' + @serchclumname + ' from '+ Rtrim(@serchtable) +' where [C_name]='''+rtrim(@serchwords)+'''' +' order BY C_id'; exec (@selectcount3); select @outputnumber=@@ROWCOUNT; END return @outputnumber; exec mytestproceduer @serchclumname='C_id', @serchwords='wen',@serchtable='T_mytest',@topnumber=1