Declaring mysql variables inside heidisql query tab

I have declared a variable in heidisql tab like this

DECLARE total_count INT DEFAULT 0;
SET total_count = 10;
select total_count;

      

but i am getting this error

/ * SQL error (1064): you have an error in your SQL syntax; check the manual corresponding to your MySQL server version for the correct syntax to use next to 'DECLARE total_count INT DEFAULT 0' on line 1 // Affected lines: 0 Lines found: 0 Warnings: 0 Duration for 0 out of 3 queries: 0.000 sec. * /

Should I declare, set and use a variable as I did or should I wrap everything inside a stored procedure or function?

+3


source to share


2 answers


Try the following:



SET @total_count := 10;
select @total_count;

      

+6


source


Maybe a little late, but dropping the semicolons working for me in 8.2.0, alas, with MS SQL 2008



DECLARE @total_count INT
SET @total_count = 10
SELECT total_count

      

0


source







All Articles