Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
smile
Starting Member
22 Posts |
Posted - 2009-05-16 : 18:00:30
|
| Hello again!I'm confused with few things around views:1) when changing the table (used to form the view), the view is also changed. Does this mean that the query (used to create the view) is executed every time when referencing the view?2) why can't we modify views formed by "Select distinct"?Thanks in advance for your help!!! |
|
|
moooris
Starting Member
11 Posts |
Posted - 2009-05-17 : 01:42:32
|
quote: Originally posted by smile Hello again!I'm confused with few things around views:1) when changing the table (used to form the view), the view is also changed. Does this mean that the query (used to create the view) is executed every time when referencing the view?2) why can't we modify views formed by "Select distinct"?Thanks in advance for your help!!!
As im noob aswell i might not be 100% correct, but yes the query of the view is executed every time you select it.Then a view i very similar to a subquery with one bonus and that is you can create triggers on views. About question 2, im not sure i understand what you mean? |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-05-17 : 02:56:25
|
quote: Originally posted by smile Hello again!I'm confused with few things around views:1) when changing the table (used to form the view), the view is also changed. Does this mean that the query (used to create the view) is executed every time when referencing the view?2) why can't we modify views formed by "Select distinct"?Thanks in advance for your help!!!
1, Are you using WITH SCHEMABINDING option inside view? Unless you use it, sp_refreshview should be run when changes are made to the objects underlying the view that affect the definition of the view. Otherwise, the view might produce unexpected results when it is queried.2, For a view to become updatable (modifiable) it should satisfy a lot of conditions like no aggregates inside, no distinct,... for full list see below (section under updatable view)http://msdn.microsoft.com/en-us/library/ms187956.aspx |
 |
|
|
smile
Starting Member
22 Posts |
Posted - 2009-05-17 : 16:44:20
|
| With your help and reading more articles concerning views, I understood the items I asked! So thanks a lot! |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-05-19 : 10:27:43
|
| welcome |
 |
|
|
|
|
|
|
|