<p>I have this script:</p>

<pre><code>select name,create_date,modify_date from sys.procedures order by modify_date desc
</code></pre>

<p>I can see what procedures were modified lately.
I will add a "where modify_date >=  "
And I'd like to use some system stored procedure, that will generate me :
drop + create scripts for the (let's say 5 matching) stored procedures</p>

<p>Can i do this somehow?</p>

<p>thanks</p>

<hr>

<p>ok. i have the final version:</p>

<p><a href="http://swooshcode.blogspot.com/2008/10/generate-stored-procedures-scripts-for.html" rel="nofollow noreferrer">http://swooshcode.blogspot.com/2008/10/generate-stored-procedures-scripts-for.html</a></p>

<p>you guys helped a lot</p>

<p>thanks</p>

You could use a cursor to iterate through each record:
```
```
DECLARE @spName NVARCHAR(128)
DECLARE myCursor CURSOR FOR SELECT name FROM sys.procedures ORDER BY modify_date DESC
OPEN myCursor
FETCH NEXT FROM myCursor INTO @spName
WHILE @@fetch_status = 0
BEGIN
    -- Process each stored procedure with a dynamic query
    PRINT @spName
FETCH NEXT FROM myCursor INTO @spName
END
CLOSE myCursor
DEALLOCATE myCursor
```
```