Are MySQL DELIMITER and DECLARE used?

I am trying to port some code from MS-SQL to MySQL and there is this code that declares a variable and then runs some select commands - it looks like this:

USE MarketDB;
GO

DECLARE @Q0 VARCHAR(16);
DECLARE @Q1 VARCHAR(16);
SET @Q0 = '05/30/2008'
SET @Q1 = '08/29/2008'

      

Now I am trying to convert this to MySQL and fail completely. Why does the following happen when a syntax error occurs:

DELIMITER ;//

BEGIN
DECLARE Q0 VARCHAR(16);
SET Q0 = '05/30/2008';
END; 
;//
DELIMITER ;

      

Thank!

+2


source to share


1 answer


In MySQL, BEGIN

and END

only act in stored procedures. Try this for MySQL translation of your above SQL Server code:



USE MarketDB;
SET @Q0 = '05/30/2008';
SET @Q1 = '08/29/2008';

      

+1


source







All Articles