Solved

doubt about update

Posted on 2013-02-06
5
214 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now