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 |
|
petek
Posting Yak Master
192 Posts |
Posted - 2008-10-24 : 10:55:11
|
| Hi all,If i create a view of a table is it possible to use the view to change data in the source table??Kind RegardsPete. |
|
|
petek
Posting Yak Master
192 Posts |
Posted - 2008-10-24 : 10:58:00
|
| further to this can i call the view from query analyser and run an update statement against it??Kind RegardsPete. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-24 : 10:59:32
|
| Yup. you can have updatable views. But not all views are updatable. There are some condition that view must follow for it to become updatable like no use of GROUPING or DISTINCT, JOIN,... The full conditions can be found belowhttp://doc.ddart.net/mssql/sql70/create_9.htm |
 |
|
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2008-10-24 : 11:02:08
|
| There are quite a few conditions, but in general the answer is yes. Look up the "Updatable views" section in the article CREATE VIEW in Books Online- Lumbago |
 |
|
|
petek
Posting Yak Master
192 Posts |
Posted - 2008-10-24 : 11:02:22
|
| thanks Visahk16.....I created my view and called the view to update another table it works. thanksKind RegardsPete. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-24 : 11:03:10
|
quote: Originally posted by petek thanks Visahk16.....I created my view and called the view to update another table it works. thanksKind RegardsPete.
Cheers |
 |
|
|
NeilG
Aged Yak Warrior
530 Posts |
Posted - 2008-10-24 : 11:12:32
|
One tip it to alway check the underlying table for Not Null columns as these will throw back an error if not included in the view select list when updateing through the view |
 |
|
|
cr8nk
Yak Posting Veteran
77 Posts |
Posted - 2008-10-25 : 00:24:39
|
| Using instead of triggers on the view also give you more flexibility into updating data from a view. Even though I am not a big fan of using them. |
 |
|
|
|
|
|