Reputation: 205
I would like to know how to alter a stored procedure from another stored procedure. I have created one stored procedure called dbo.change
, and in this procedure I would like to alter other stored procedure that needs to be altered.
But currently I use alter procedure
and when the change procedure is compiling it fails at the alter. Is there a method of doing this?
Upvotes: 0
Views: 2751
Reputation: 46203
You need to use dynamic SQL to alter a stored procedure from within another. For example:
ALTER PROC dbo.Change
AS
EXEC sp_executesql N'ALTER PROC dbo.SomeOtherProc AS ...';
GO
Upvotes: 5