Querying system table to retrieve Views code

  • Hi all,

    Is there a way in t-sql that will allow me to retrieve the statements of a view. e.g.

    select * from systable_code where view_name = 'my_view'

    and the results would be something like...

    ID sql

    1 select * from tbl_customers

    I am creating an application that should allow to compare the two views code as it is in the database.

    Thanks,

    Husain

  • This might help get you started. Notice that longer views are broken into multiple lines.

    select B.name, A.text

    FROM syscomments A

    JOIN sysobjects B

    ON A.id = B.id

    WHERE B.type = 'V'

    ORDER BY A.id

  • Hi Ken,

    This is exactly what I was looking for!

    Thanks

    Husain

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

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