January 6, 2006 at 5:43 am
I am trying to update data by using a SP to update a view that is made up of two tables. I get an error back saying the view is not updatable because the modification affects multiple base tables. (the two tables are a One to One join if that matters) However I can cut and paste the code in the Query Analyzer and it works fine. I can also manually edit the view with no problems. I can always edit the SP to update the two tables directly, but I liked the simplicity of using the view. Does anyone know why the SP wonโt work while the other ways do.
Thanks,
fryere
fryere
January 6, 2006 at 5:51 am
Sorry,
I am not sure what I did the first time I ran the update code with the query analyzer, but I tried it again and got the same error mentioned above. I guess I will just change the SP to update the two tables independently.
Thanks.
fryere
January 6, 2006 at 6:09 am
Fryere,
when you try to update a view which contains columns from more than one table you need to define an INSTEAD OF Trigger on your view. The trigger should when handle which columns in which tables need to be updated. Without the trigger SQL server don't always know which table needs to be updated.
By the way, don't let yourself be fooled by EM, because there it will work, because in the background EM does direct updates on the tables.
Markus
[font="Verdana"]Markus Bohse[/font]
January 6, 2006 at 7:12 am
MarkusB,
Thanks for the reply. Where do you access Triggers for Views. I can't seem to find it.
Thanks.
fryere
January 6, 2006 at 7:59 am
Look in BOL for INSTED OF TRIGGERs. There are some examples.
Markus
[font="Verdana"]Markus Bohse[/font]
October 3, 2008 at 7:56 am
Use Instead of Triggers on the Views to Delete or Update Records directly from the view.
October 3, 2008 at 11:06 am
chakri002 (10/3/2008)
Use Instead of Triggers on the Views to Delete or Update Records directly from the view.
You did notice that the thread you answered was 2 years old?
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
October 3, 2008 at 11:30 am
Not to mention the answer he gave had already been given, better, and in more detail before he bumped it. That post was in general a failure of epic proportions.
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply