I think the error you're encountering is related to a syntax error in the SQL statement that is dynamically constructed within the stored procedure.
There is a space issue between the CREATE OR ALTER VIEW
and the @ViewName
.
Try to update your query like below :
USE gold_db
GO
CREATE OR ALTER PROC CreateSQLServerlessView_gold @ViewName nvarchar (100)
AS
BEGIN
DECLARE @statement varchar(max)
SET @statement = N'CREATE OR ALTER VIEW ' + @ViewName + ' AS
SELECT *
FROM
OPENROWSET(
BULK ''https://ebgenlake2.dfs.core.windows.net/gold/SalesLT/' + @ViewName + '/'',
FORMAT = ''DELTA''
) AS [result]
'
EXEC (@statement)
END
GO