BEGIN  
set @s_sql=concat('select * from test l where l.t=1 ',a,' limit ',b,' , ', c);  
  prepare stmt1 from @s_sql;  
  execute stmt1;  
  deallocate prepare stmt1;  
END  
参数:a int,b int,c varchar(500)   
------------------mysql 存储过程写法  
create proc test  
@a int,  
@b int,  
@c varchar(500)  
as  declare @s_sql nvarchar(max)  
set @s_sql = 'select * from test1 a where a.y=1'+@c =(select top a,b from test1)  
exec(@s_sql)  消息 102,级别 15,状态 1,过程 test,第 8 行  
'=' 附近有语法错误。  
消息 102,级别 15,状态 1,过程 test,第 8 行  
'a' 附近有语法错误。  
-----------------------我想用 sql server 2005 数据库存储过程 实现上面mysql存储的功能  =====================================================第二个  BEGIN  
set @s_sql= concat(' select count(distinct b.id) into @tempcount from ',filter);  
  prepare stmt1 from @s_sql;  
  execute stmt1;  
  deallocate prepare stmt1;  
set totalNum=@tempcount;  
END  
-------------------- 以上mysql 的存储过程  
create proc test  
@a varchar(500)  as  
declare @s_sql nvarchar(max)
set @s_sql= 'select count(distinct b.id) into @tempcount from ',+@a
set totalNum=@tempcount;  
exec(@s_sql)  
go  
---------------------------------
  多少分都给,帮帮忙。 本人在实现一个 SQL SERVER 2005 分页功能。

解决方案 »

  1.   

    这句拼完之后是什么样子,没能理解:
    set @s_sql = 'select * from test1 a where a.y=1'+@c =(select top a,b from test1) 你把想拼出来的串写出来,我看看怎么改上面的语句。
      

  2.   

    这句拼完之后是什么样子,没能理解:
    set @s_sql = 'select * from test1 a where a.y=1'+@c =(select top a,b from test1)  你把想拼出来的串写出来,我看看怎么改上面的语句。
      

  3.   

     
    @a int,   
    @b int,   
    @c varchar(500)   
     就这三个参数