user3086751
user3086751

Reputation: 205

Altering stored procedure from another procedure

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

Answers (1)

Dan Guzman
Dan Guzman

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

Related Questions