>
>My problem is more basic in fact. I don't understand why the first sql generates and "alter procedure" statement, where I was hoping that it would generate an executing sql.
>
>
An ALTER statement is the script that SSMS generates when you right-click on a stored procedure and choose to modify it.
When you execute that script (after making any changes), SSMS executes the ALTER script, which (essentially) pushes the script back to the database.
Generally, here are the things you can do with a proc...
CREATE PROCEDURE dbo.Whatever
as
-- code for procedure
When you "execute" this script, it will save the proc back to the database (if it doesn't already exist)
ALTER PROCEDURE dbo.Whatever
as
-- change existing code
When you "execute" this script, it will push the changes back to the database and overwrite the existing proc. Executing this script (that begins with an ALTER PROCEDURE statement) doesn't run the code on the inside...it basically pushes the changes back to the database.
Now...you can also do these 2...
EXEC dbo.MyProc
This will actually run the code inside the procedure
And finally, you can do this.;..
DROP PROCEDURE
That will delete the procedure from the database