Views

  • Hi all

    Please help me understand the process on Views in SQL Server

    Table:

    create table viewstest

    (Col1 int, Col2 int, Col3 int)

    go

    insert into viewstest

    values

    ('1', '1', '1')

    ,('2', '2', '2')

    ,('3', '3', '3')

    ,('4', '4', '4')

    ,('5', '5', '5')

    ,('6', '6', '6')

    ,('7', '7', '7')

    View:

    create view [dbo].[VW]

    as

    select * from viewstest

    where Col1 = '1'

    GO

    Ok

    Why is it that when I update or insert data in the view, it also updates the underlying table?

    Is that normal?

    Thanks

  • Views are just saved select statements. They aren't tables, they don't store data. Where else would the changes go when you update a view?

    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

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

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