MySQL stored procedure parameters don't seem to work with special character @?

MySQLMySQLi Database

You cannot give MySQL stored procedure parameter with @ in the beginning. You can give @ sign in user-defined variables.

Following is the syntax −

SET @yourVariableName=yourValue;

Let us implement the above syntax to correctly place @sign −

mysql> DELIMITER //
mysql> CREATE PROCEDURE declare_Variable(IN StudentName varchar(100))
      SET @Name=StudentName;
      SELECT @Name;
Query OK, 0 rows affected (0.12 sec)
mysql> DELIMITER ;

Now you can call stored procedure with the help of CALL command −

mysql> call declare_Variable('John Smith');

This will produce the following output −

| @Name      |
| John Smith |
1 row in set (0.00 sec)
Query OK, 0 rows affected, 1 warning (0.03 sec)
Updated on 22-Aug-2019 06:58:36