Creating View

  • I have a table with about 50 columns...I want to create a view with the column names same as the one in original table but with #1 appended to it...

     

    for eg  Name should be Name1,ssn should be ssn1 and so on......

    Any help will be highly appreciated

    Jol

     

     

     


    Kindest Regards,

    Joel

  • Write a select statement pulling back the metadata to do most of the work for you and execute it in QA:

    SELECT COLUMN_NAME + '1,
    ' FROM INFORMATION_SCHEMA.Columns
    WHERE TABLE_NAME = '<Your table name>'
    ORDER BY ORDINAL_POSITION

    Copy the resulting output and add on your CREATE VIEW and FROM statements and you have your DDL query to create the view.

    K. Brian Kelley
    @kbriankelley

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

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