0

I'm very new to SQL statements to update / manage records.

I have a very simple request and I have look into it online but it doesnt fully make sense as I am new.

My query is

Update [Data].[viewAppFieldList]
Set level = 308
Where fieldid = 23456

When I run it of course I get the error that it failed because it contains a derived or constant field.

Can someone explain why it is doing that, my assumption is because it is applicable in more than one place.

Secondly how do I go about manipulating it so this can be changed?

Thank you!

Nathan
  • 107
  • 8
  • Try to research more. You can also try to look at this link. https://stackoverflow.com/questions/25472378/update-or-insert-of-view-or-function-failed-because-it-contains-a-derived-or-con – TraxX Jan 04 '18 at 02:59
  • Further down the rabbit hole I go. So I looked at the instead of and as not knowing as much as I would like I dont see it updating. Here is what I wrote. Create Trigger trg_update On [Data].[viewAppFieldList] Instead of Update As Begin Update [Data].[viewAppFieldList] set level = 308 where fieldid = 23456 End But it didnt update anything. – Nathan Jan 04 '18 at 03:19
  • It looks like you're updating a VIEW. VIEWs are only updatable in a [narrow set of circumstances](https://msdn.microsoft.com/en-us/library/ms180800(v=sql.105).aspx). – Bacon Bits Jan 04 '18 at 06:06
  • Your comment here and the trigger you created shows that you *really* don't understand triggers and you've also just broken updating for this view as long as this trigger is in place. If you really created that trigger, you'll want to remove it. You should instead start by looking at the view definition and seeing which tables `level` and `fieldid` are from, and then try updating that table directly instead of the view. – Bacon Bits Jan 04 '18 at 06:09

0 Answers0