Why does this code not accept the parameters inside SQL create view from the stored procedure?
I want to pass the value of stored procedure parameters to create a view
I want to pass the value of stored procedure parameters to create a view
Code:
Create PROCEDURE MyProcedure
@ID int
AS
BEGIN
-- if object_id ('myview' ,'v') is not null
DROP VIEW IF EXISTS myview
DECLARE @viewName VARCHAR(100) = 'MyView';
DECLARE @viewSQL NVARCHAR(MAX) = 'CREATE VIEW ' + @viewName + ' AS SELECT * FROM Client' + 'where ID=@ID';
EXEC sp_executesql @viewSQL;
END;