Any pointers on how I can programmatically get exactly the identical stored procedure source from SQL Server 2005, as when I right-click on that stored procedure in SQL Serv
Use the following select statement to get all the whole definition:
select ROUTINE_DEFINITION from INFORMATION_SCHEMA.ROUTINES Where ROUTINE_NAME='someprocname'
my guess is that SSMS and other tools read this out and make changes where necessary such as changing CREATE to ALTER. As far as I know SQL stores not other representations of the procedure