I have an error in my code when I execute, it gives me an error, I don't know what should I change.
My code is:
ALTER PROCEDURE [dbo].[SP_OneColumnIntoView]
AS
BEGIN
EXEC('CREATE VIEW OneColumnIntoView2
AS
SELECT *
FROM OPENJSON ((SELECT QUOTENAME(STRING_AGG(VALUE, ''), '') AS JC
FROM OneColumnJsonFood))
;WITH (FID INT, Fname NVARCHAR(50), Ftype NVARCHAR(20),
Fcount INT, Datetype NVARCHAR(4000), Fregion NVARCHAR(50),
Fdescription NVARCHAR(100)) AS WithJson
')
END
Error:
Msg 156, Level 15, State 1, Procedure OneColumnIntoView2, Line 4 [Batch Start Line 2]
Incorrect syntax near the keyword 'FROM'
PS: If I put ;
it gave me this error:
Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…