因为是很多页面传送过来的SQL,
比如$sql="select * from tb1";或者$sql="select * from tb2 where user=3";
每次只有一条查询语句发送过来,应该如何写这个存储过程呢?

解决方案 »

  1.   

    --try
    create proc test 
    (
         @sql  varchar(8000)
    )
     as
    exec (@sql)
    go
      

  2.   

    不行哦
    create procedure p1(@sql varchar(300))
     as 
    exec(@sql)
    GO;
    语法对么,他报语法错误
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@sql varchar(300)) as exec(@sql) go' at line 1