ドキュメントから:DECLARE is permitted only inside a BEGIN ... END compound statement and must be at its start, before any other statements.
更新
これに近いものがあります。 CONVERT
の構文を整理する必要があります これはMySQLでは異なります。
DELIMITER $$
CREATE PROCEDURE test()
BEGIN
DECLARE dateInsert DATETIME;
SET dateInsert = '1900-01-01';
WHILE dateInsert < '2100-01-01' DO
BEGIN
INSERT INTO DateLookup
(
DateKey, DateFull, FullYear,
QuarterNumber, WeekNumber, WeekDayName,
MonthDay, MonthName, YearDay,
DateDefinition,
CharacterDate,
WeekDay,
MonthNumber
)
SELECT
CONVERT(VARCHAR(8), dateInsert, 112), dateInsert, YEAR(@Date),
DATEPART(qq, dateInsert), DATEPART(ww, dateInsert), DATENAME(dw, dateInsert),
DATEPART(dd, dateInsert), DATENAME(mm, dateInsert), DATEPART(dy,@Date),
DATENAME(mm, dateInsert) + ' ' + CAST(DATEPART(dd, dateInsert) AS CHAR(2)) + ',
' + CAST(DATEPART(yy, dateInsert) AS CHAR(4)),
CONVERT(VARCHAR(10), dateInsert, 101),
DATEPART(dw, dateInsert),
DATEPART(mm, dateInsert)
SET dateInsert = DATEADD(dd, 1, dateInsert)
END
END WHILE;
END $$