1 ------------------------------------
 2 --用途:查询列表,返回前几条或者全部
 3 --项目名称:
 4 --说明:
 5 --时间:2012/8/15 12:16:41
 6 ------------------------------------
 7 ALTER PROCEDURE [dbo].[GetTopList_Pro]
 8 @tbname varchar(30),
 9 @cols varchar(400),
10 @top int=0,
11 @strWhere varchar(1000)='',
12 @orderby varchar(1000)=''
13 AS
14     declare @strTop varchar(30)=''
15     if @strWhere!=''
16     set @strWhere=N' where '+ @strWhere
17 
18     if @orderby!=''
19     set @orderby=N' order by '+ @orderby
20 
21     if @cols=''   
22     set @cols=N' * '
23 
24     if @top>0
25     set @strTop=N' top '+ convert(varchar,@top)
26     
27     /* SET NOCOUNT ON */
28     exec(N'select  '
29     +N' '+@strTop
30     +N' '+@cols
31     +N' from '+@tbname
32     +N' '+@strWhere
33     +N' '+@orderby)
34     
35     
36     print N'select  '
37     +N' '+@strTop
38     +N' '+@cols
39     +N' from '+@tbname
40     +N' '+@strWhere
41     +N' '+@orderby
42     RETURN

 

 

相关文章:

  • 2021-05-20
  • 2021-09-29
  • 2021-07-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-17
猜你喜欢
  • 2021-11-08
  • 2021-09-11
  • 2022-12-23
  • 2022-12-23
  • 2021-06-29
  • 2021-09-09
  • 2021-11-09
相关资源
相似解决方案