从我的数据库脚本执行以下语句时出现错误。
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PROJ_GetQuestions]') AND type in (N'P', N'PC'))
BEGIN
EXEC('
CREATE PROCEDURE [dbo].[PROJ_GetQuestions]
(
@TestID INTEGER
)
AS
SELECT b.* FROM [IER_TestsCatalogue] a
INNER JOIN [IER_QuestionsCatalogue] b
ON ',' + a.Selected_CategoryIds + ',' LIKE '%,' + CAST(Category_Id AS VARCHAR(10)) + ',%'
WHERE a.Test_Id = @TestID Order by NEWID()
RETURN
')
END
执行上述语句后出错。
Schema Creation Failed: Incorrect syntax near '%'.