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
 update joined view

Author  Topic 

musclebreast
Yak Posting Veteran

77 Posts

Posted - 2014-08-15 : 09:12:40
Hi,


I create a view with 2 joined tables:



with cte as (
select
DataID,
Name,
SubType,
FileType,
MimeType,
VersionID,
Version

from dtree A1, dversdata A2

where A1.dataid=A2.Docid And A1.Subtype='144'

AND

A2.mimetype='application/news-message-id'



)



update cte set MimeType = 'application/x-outlook-msg', Subtype=749




what I want to do is to update two columns. Both are from different tables and I get an error.....Has anybody an idea how I can do it?

Kind regards,

Lara

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-08-15 : 09:27:04
I suppose your getting the message:

Msg 4405, Level 16, State 1, Line 6
View or function 'cte' is not updatable because the modification affects multiple base tables.

which pretty much means what it says. You can't do this in one update. You'll need two update statements (and maybe two CTEs) to finish the job
Go to Top of Page
   

- Advertisement -