Solved

doubt about update

Posted on 2013-02-06
5
218 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 143

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need help with a query 6 82
CREATE DATABASE ENCRYPTION KEY 1 82
display data in text field from data base for updating 6 77
Help with SQL - TOP 10 by date and by group 13 45
This article will describe one method to parse a delimited string into a table of data.   Why would I do that you ask?  Let's say that you need to pass multiple parameters into a stored procedure to search for.  For our sake, we'll say that we wa…
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…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

739 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