How to add a column to a view

  • How to add a column to a view.

    In ABC database, in the table TABLE1, there is a column called “COLUMN1”.

    how to publish this column in the view “VIEW1” under the name “COLUMN1”?

  • ALTER VIEW <ViewName>

    AS

    <Entire select statement here>

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • If your view contains something like this

    SELECT * FROM FooTable

    ... and you want to see your new columns automatically after adding to your table, have a look to BOL for sp_refreshview.

    ... after this, forget sp_refreshview and get rid of "SELECT *" 😉

    Greets

    Flo

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

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