There’s probably an article from 20 years covering this.Anybody asking such a question needs to read a manual and feel lucky they exist.Let me know if this solution satisfies the need of updating two tables in a single statement.If not, I would love to know the reason, you want to update two more tables in a single statement. SQLAuthority.com)I’m stunned that this needs discussing in 2017.
In any case I did cahnge @unit with '71054' and scratched the declare. Worked perfectly Tried to update the t_cmnf and got an error. One way to deal with this is to create an INSTEAD OF UPDATE trigger on view which updates the base tables instead of updating the view directly. Post.aspx? Card Gunner I didn't put all the tables in the code. I'll have to see if '71054' can be called as a parameter in VS 2003. Can you do this type of statement when creating a view? Card Gunner Originally posted by jimf Found this trivia on the net a while ago DECLARE @Table A TABLE (i INT)DECLARE @Table B TABLE (i INT)SELECT * FROM @Table ASELECT * FROM @Table BINSERT @Table AOUTPUT inserted.i INTO @Table BSELECT 1 UNION ALLSELECT 2 UNION ALLSELECT 3SELECT * FROM @Table ASELECT * FROM @Table BOriginally posted by cardgunner I was afraid of that.Card Gunner create view tmp_mfg_unit_2 as select t_cmnf, t_clot from ttscfg200120 --objects where t_clot='23332' union all select t_cmnf, t_clot from terext401120 --rental contract lines where t_clot='23332' update tmp_mfg_unit_2 set t_cmnf='OTH' Server: Msg 4416, Level 16, State 5, Line 1 UNION ALL view 'tmp_mfg_unit_2' is not updatable because the definition contains a disallowed construct.create view tmp_mfg_unit_2 as select t_cmnf, t_clot from ttscfg200120 --objects union all select t_cmnf, t_clot from terext401120 --rental contract lines update tmp_mfg_unit_2 set t_cmnf='OTH' where t_clot='23332' Server: Msg 4440, Level 16, State 9, Line 1 UNION ALL view 'tmp_mfg_unit_2' is not updatable because a primary key was not found on table '[ttscfg200120]'.
I am trying like:update tablename1 t1,tablename2 t2 set t1.fieldname1 = t2.fieldname1 = 'value' where condition;orupdate tablename1 t1,tablename2 t2 set t1.fieldname1 = 'value' t2.fieldname1 = value where condition; Plzzzzzz help me. I'll have to see if '71054' can be called as a parameter in VS 2003.