How to extract SQL Server object definition in t-sql

Dear reader, thanks for visiting!

The post has been moved to my new blogging site – http://www.mssqlinsider.com.

You can read the complete post there.

Advertisements

4 comments on “How to extract SQL Server object definition in t-sql

  1. Hi,
    Is it possible that the result of sp_helptext and sys.sql_modules has a diffrence.

    SQL DBA

    • Hi there,
      I believe the output should be the same as long as the queried object falls in the scope of both sp_helptext and sys.sql_modules. Probably the formatting of the output could be different but the definition should not differ.

  2. Try creating a simple View called my_View. Run sp_helptext ‘my_View’. Then rename the View to my_View2. Then run the query again sp_helptext ‘my_View2’. The results will show CREATE VIEW dbo.my_View and not the new name. What’s up with that?

    OBJECT_DEFINITION gives the same incorrect results.

  3. Apparently you need to make sure you don’t rename, but drop and recreate with stored procedures, functions, triggers and views.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s