![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I am having trouble trying to update a field based in a table based on the results from another table. I want to update a tables field based on the results of a view using another field as the join. VIEW1 contains partnumber and orderqty (this is a grouped result from another table) TABLE1 contains partnumber and onorderqty I would like to update TABLE1.onorderqty to TABLE1.onorderqty + VIEW1.orderqty hopefully in VB so I can run it on a form close button. But SQL Server does not seem to like 2 tables in an update query. Can any one help ? Liam |
#3
| |||
| |||
|
|
"Liam" <lm2000uk (AT) hotmail (DOT) com> wrote in news:bg3cc9$dnt$1 (AT) titan (DOT) btinternet.com: I am having trouble trying to update a field based in a table based on the results from another table. I want to update a tables field based on the results of a view using another field as the join. VIEW1 contains partnumber and orderqty (this is a grouped result from another table) TABLE1 contains partnumber and onorderqty I would like to update TABLE1.onorderqty to TABLE1.onorderqty + VIEW1.orderqty hopefully in VB so I can run it on a form close button. But SQL Server does not seem to like 2 tables in an update query. Can any one help ? Liam A simple way would be to include onorderquery in View1. Then one can update View1 setting onorderquery = onorderquery + orderquery. Views in SQL-Server are essentially Tables comprised of (maybe filtered) columns from other persistent tables. As such they are powerful and dangerous too. Updating the view will update the table. As I've mentioned before, this somewhat erodes the whole notion of table as a collection of intrinsically related data. The relationships among columns can now be quite arbitrary, and meaningful or meaningless; the location of the columns as far as tables go has become or is becoming irrelevant. -- Lyle ---------------------------------------------------------------------------- |
#4
| |||
| |||
|
|
"Liam" <lm2000uk (AT) hotmail (DOT) com> wrote in message news:bg3cc9$dnt$1 (AT) titan (DOT) btinternet.com... I am having trouble trying to update a field based in a table based on the results from another table. I want to update a tables field based on the results of a view using another field as the join. VIEW1 contains partnumber and orderqty (this is a grouped result from another table) TABLE1 contains partnumber and onorderqty I would like to update TABLE1.onorderqty to TABLE1.onorderqty + VIEW1.orderqty hopefully in VB so I can run it on a form close button. But SQL Server does not seem to like 2 tables in an update query. Can any one help ? Liam Without seeing your table structures it's impossible to say, but perhaps something along these lines: --------------------- UPDATE TABLE1 SET onorderqty = v.onorderqty FROM VIEW1 AS v WHERE v.partnumber = TABLE1.partnumber --------------------- But this may or may not work depending on composition of the tables making up the view. Post the DDL for the tables and the view with some sample data and someone will likely be able to help. ================================================== ======= |
#5
| |||
| |||
|
|
PS.. How do you run a stored procedure from Access VB ??? Liam |
![]() |
| Thread Tools | |
| Display Modes | |
| |