Retrieving the query from the view

  • Hi,

    I want to have the contents of the view, means query of the view.

    Actually i want to read all the view names and the query of the view from the database and then, i want to store them in another table. To see the contents of the view we can give sp_helptext <viewname>, but the contents i want to store in a variable so that we can store them in the table.

    Thanks in advance.

    Thiru 

  • Assuming that the view definition (text) is less that nvarchar(4000) in length you can use

    SELECT TABLE_NAME AS Name, VIEW_DEFINITON  AS DEFINITION

    FROM INFORMATION_SCHEMA.VIEWS

     

    HTH

     


    * Noel

  • INSERT INTO ... EXEC sp_helptext would be another option.

    but the contents i want to store in a variable so that we can store them in the table.

    What do you mean here? Sounds to me like you're trying to reinvent the wheel.

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

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

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