Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Views Expand / Collapse
Author
Message
Posted Monday, August 27, 2012 5:39 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Yesterday @ 3:14 AM
Points: 1,375, Visits: 2,670
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
Post #1350329
Posted Monday, August 27, 2012 6:05 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Yesterday @ 3:52 PM
Points: 42,849, Visits: 35,978
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 2008, MVP
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

Post #1350340
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse