Results 1 to 4 of 4

Thread: syscomments

  1. #1
    Join Date
    May 2009
    Posts
    41

    syscomments

    Hi

    can someone tell me how to use syscomments table.

    The thing is, i need to find the text of a system stored procedure but i am not sure what condition to use in the query.

    sp_helptext did help, but i wanted to use syscomments table.

    thanks!!

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    Stored procedure text may be split into multiple lines in syscomments.

    Get stored procedure object_id and query syscomments.

    SQL 2005 has sys.sql_modules view which has all text in one row.

  3. #3
    Join Date
    May 2009
    Posts
    41
    But if i need the text for a Stored Procedure in master database, say 'sp_addalias', i need to query sysobjects table to get the id for the stated Stored Procedure. and by using that id, i can query only syscomments table, not sys.sql_modules view, i guess.

    sys.sql_modules view contains the stored procedure entries of msdb system databse only i think. and the object_id of those stored procedures can be taken from the view sys.objects system view.

    pls correct me if i m wrong somewhere or if i am lacking knowledge somewhere!!!

    thanks!!!

  4. #4
    Join Date
    Sep 2002
    Posts
    5,938
    The view is in every db.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •