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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 updating view

Author  Topic 

mana
Posting Yak Master

102 Posts

Posted - 2014-09-10 : 03:17:15
hello,

i have a view and i want to update it, i wrote the below code but it has the below error, can you help me please?

Msg 4403, Level 16, State 1, Line 1
The view or 'dbo.View_1' function can not be updated because it contains aggregates, or a DISTINCT or GROUP BY clause, or PIVOT or UNPIVOT operator a.

the below is my code:
update dbo.View_1
set Teamleader= (case when E.Von_Adresse = V.Von_Adresse
or LEFT(E.Von_Adresse,3) = LEFT(V.Von_Adresse ,3) then V.Label end)
from dbo.View_1 AS E, AMPPU_Teamleader_Von_Adresse AS V
where E.Teamleader is null;

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2014-09-10 : 08:23:52
Does the view contain any distinct or group by clause or pivot or unpivot? Look in the remarks section of this page to see the restrictions on updating views: http://msdn.microsoft.com/en-us/library/ms187956.aspx

That aside, I didn't understand the logic of the update statement - i.e., how are the two tables related?
Go to Top of Page
   

- Advertisement -