Using Alter View in sproc?
I am getting errors when trying to write a stored procedure with alter view statements in it. Can this not be done or is my syntax just off. If it can't be done is there a common work around or different method I should consider?
Thanks
[247 byte] By [
bobbye] at [2008-2-22]
You most probably have the ALTER VIEW in the body of the SP as static SQL statement. This is not possible since DDLs like ALTER VIEW, CREATE VIEW, CREATE PROCEDURE etc needs to be only DDL statement in the batch. You have to either do ALTER VIEW in it's own batch or execute it dynamically using EXECUTE or sp_executesql.