delimiter @@;
declare @i int;
@@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 'declare @i int;
@@' at line 1这为什么都错啊,变量不是这么申明的?

解决方案 »

  1.   

    定义变量必须在存储过程或者函数或者触发器中定义 这点和sqlserver不一样
    也可不必定义
    mysql> set @a=1;
    Query OK, 0 rows affected (0.00 sec)mysql> select @a;
    +------+
    | @a   |
    +------+
    |    1 |
    +------+
    1 row in set (0.00 sec)mysql>
      

  2.   

    MYSQL不支持匿名块,必须在SP中声明
    declare i int;
      

  3.   

    set 可以。
    declare必须在sp中声明使用
      

  4.   

    MYSQL中不支持匿名块,只能把这个过程语句放在存储过程中执行。你可以象1楼一样,直接使用,不要DECLARE