Programmatically retrieve SQL Server stored procedure source that is identical to the source returned by the SQL Server Management Studio gui?

后端 未结 9 2043
孤独总比滥情好
孤独总比滥情好 2020-11-30 20:38

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

9条回答
  •  醉话见心
    2020-11-30 21:03

    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

提交回复
热议问题