Is there a way to query SQL statement of a view?

  • That's just it... I need to read SQL statement of a view somehow to be able manipulate it programmatically.

    Is it possible?

    [SQL Server 2000 or 2005]

    Thank you,

    Natasha

  • In 2005, the text of the view is in sys.sql_modules in the definition column. In 2000, it's in syscomments (but might be split across multiple rows because of the 4,000-character limit). You can query those.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Just found it myself! 🙂

    sp_helptext

    and it workds!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply