Solved

doubt about update

Posted on 2013-02-06
5
216 Views
Last Modified: 2013-02-08
Hello Guys

How can I do this update

I have a tableA and tableB

Update TableA set valor=tableB.valor, qtde=tableB.Value where TableA.code = 123

I don't know how to go on now

In my tableB I have two fields named:

TableB.prod and TableB.code
both field can be cross with tableA
TableA.prod and TableA.code

I thanks any help
0
Comment
Question by:hidrau
5 Comments
 
LVL 23

Accepted Solution

by:
Ioannis Paraskevopoulos earned 125 total points
ID: 38859421
Hi,

Does this help:

UPDATE	TableA
SET		valor = B.valor,
		qtde = B.Value
FROM	TableA A
		JOIN TableB B
			ON A.prod = B.prod
			AND A.code = B.code

Open in new window


Giannis
0
 
LVL 3

Assisted Solution

by:Nalinkumarbalaji
Nalinkumarbalaji earned 125 total points
ID: 38859423
Select the Below Query - Check and Update the Table. -  I am not using the SQL for Testing this QUERY. This is the sample method. You have to check the TableA and TableB common field and put a join to that field for update.

SELECT

Select  TableA.valor, tableB.valor, TableA.qtde, tableB.Value FROM TABLE A, TABLE B where TableA.code = 123
AND TABLEA.Code=TABLEB.CODE
AND TABLEA.PROD=TABLEB.PROD
Goup by TableA.valor, tableB.valor, TableA.qtde, tableB.Value


Update TableA set valor=tableB.valor, qtde=tableB.Value where TableA.code = 123
AND TABLEA.Code=TABLEB.CODE
AND TABLEA.PROD=TABLEB.PROD
0
 
LVL 11

Assisted Solution

by:David Kroll
David Kroll earned 125 total points
ID: 38859428
update TableA
set value = TableB.valor,
qtde = TableB.value
from TableA
inner join TableB on (TableB.code = TableA.Code) or (TableB.prod = TableA.prod)
where TableA.code = 123
0
 
LVL 142

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 125 total points
ID: 38859471
0
 
LVL 1

Author Closing Comment

by:hidrau
ID: 38868707
thanks everybody
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question