[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

doubt about update

Posted on 2013-02-06
5
Medium Priority
?
224 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 500 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 500 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 500 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 143

Assisted Solution

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

Author Closing Comment

by:hidrau
ID: 38868707
thanks everybody
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

by Mark Wills PIVOT is a great facility and solves many an EAV (Entity - Attribute - Value) type transformation where we need the information held as data within a column to become columns in their own right. Now, in some cases that is relatively…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?

864 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