Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You cannot add a trigger to a system table, but you can create a DDL trigger that will fire on the ALTER PROC statement - example:</p> <pre><code>ALTER TRIGGER DDL_PROC ON DATABASE FOR ALTER_PROCEDURE AS DECLARE @data XML, @ObjectName sysname, @ParamCount int SET @data = EVENTDATA() SET @ObjectName = @data.value('(/EVENT_INSTANCE/ObjectName)[1]', 'sysname') PRINT 'You have changed procedure: ' + @ObjectName SELECT @ParamCount = COUNT(*) FROM sys.parameters WHERE object_id = OBJECT_ID(@ObjectName) RAISERROR('This procedure now has %i parameter(s)',0,0,@ParamCount) GO </code></pre> <p>I'm not sure how to get the previous parameter list or if it's even possible - does anybody know?</p> <p>I would agree with Charles' suggestion to make new parameters optional if possible - existing code will not break and you only have to find the references if you <em>must</em> add the parameter to the call.</p> <p>Scripting out the database seems like the long way around. A simple query such as the following should find all references to your proc (within your database):</p> <pre><code>SELECT so.name, so.type_desc FROM sys.all_objects so JOIN sys.all_sql_modules sm ON so.[object_id] = sm.[object_id] WHERE sm.[definition] LIKE '%&lt;proc name&gt;%' </code></pre> <p>This is the same thing, but will also work in previous versions of SQL server:</p> <pre><code>SELECT so.name, so.type FROM syscomments sc JOIN sysobjects so ON sc.id = so.id where text like '%&lt;proc name&gt;%' </code></pre> <p>Hope this helps,</p> <p>MDD</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload