我正在将我的数据库系统从MySql重写为MSSQL。在我目前的一段代码中,我得到了错误:
SQL80001:';'附近的语法不正确。期待对话。
CREATE PROCEDURE [dbo].[addAnime]
@$animeID INT,
@$animeName VARCHAR(100),
@$animeEpisodes INT,
@$animeSeasons INT,
@$animeGenre1 VARCHAR(100),
@$animeGenre2 VARCHAR(100),
@$animeGenre3 VARCHAR(100),
@$animeArtist VARCHAR(100),
@$animeStudio VARCHAR(100),
@$animeReleaseDate VARCHAR(100),
@$animeDescription VARCHAR(8000),
@$animeImageLocation VARCHAR(1000)
AS
BEGIN
IF NOT EXISTS (SELECT * FROM animedatabase.anime WHERE animeName LIKE @$animeName)
INSERT INTO animedatabase.anime(animeID, animeName, episodes, seasons, genre1, genre2, genre3, artist, studio, releaseDate, animeDescription, imageLocation)
VALUES(@$animeID, @$animeName, @$animeEpisodes, @$animeSeasons, @$animeGenre1, @$animeGenre2, @$animeGenre3, @$animeArtist, @$animeStudio, @$animeReleaseDate, @$animeDescription, @$animeImageLocation);
ELSE IF ((SELECT COUNT(*) FROM animedatabase.anime WHERE animeName LIKE @$animeName) = 1)
UPDATE
animedatabase.anime
SET
animeID = @$animeID,
animeName = @$animeName,
episodes = @$animeEpisodes,
seasons = @$animeSeasons,
genre1 = @$animeGenre1,
genre2 = @$animeGenre2,
genre3 = @$animeGenre3,
artist = @$animeArtist,
studio = @$animeStudio,
releaseDate = @$animeReleaseDate,
animeDescription = @$animeDescription,
imageLocation = @$animeImageLocation
WHERE animedatabase.anime.animename LIKE @$animeName;
END
END
END;
我在结构和命名方面做了很多改动,但没有一个能解决问题。我似乎无法找到我做错的事。任何帮助将不胜感激。
提前致谢。