473,434 Members | 1,403 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,434 software developers and data experts.

Update Table Column based on value from another table?

Hi, I have two tables. I want to update two columns in my first table,
[ADD_BSL_SALES] and [ADD_BSL_COST] with two values [Sales] and
[Costs] held in my #temp table but based on a RUN_DATE from my first
table.

Can anyone point me in the right direction?

Thanks in Advance 

Bryan

CREATE TABLE [GROSMARG_AUDIT_ADDITION] (
[RUN_DATE] [datetime] NULL ,
[SALES_DIFF] [numeric](19, 6) NULL ,
[COST_DIFF] [numeric](19, 6) NULL ,
[ADD_BSL_SALES] [numeric](18, 0) NULL ,
[ADD_BSL_COST] [numeric](18, 0) NULL ,
[ADD_SALES_DIFF] [numeric](18, 0) NULL ,
[ADD_COST_DIFF] [numeric](18, 0) NULL
) ON [PRIMARY]
GO
INSERT RUN_DATE,datetime,
INSERT SALES_DIFF,numeric(19,6),
INSERT COST_DIFF,numeric(19,6)
INSERT ADD_BSL_SALES,numeric(18,0),
INSERT ADD_BSL_COST,numeric(18,0),
INSERT ADD_SALES_DIFF,numeric(18,0)
INSERT ADD_COST_DIFF,numeric(18,0)

--- Second Table

CREATE TABLE #DUPTOTALS
[Sales]
[Costs]

Sep 2 '05 #1
1 11721
On 2 Sep 2005 04:00:29 -0700, Bryan wrote:
Hi, I have two tables. I want to update two columns in my first table,
[ADD_BSL_SALES] and [ADD_BSL_COST] with two values [Sales] and
[Costs] held in my #temp table but based on a RUN_DATE from my first
table.

Can anyone point me in the right direction?

Thanks in Advance ?

Bryan
Hi Bryan,

Your post appears to be incomplete. After the first CREATE TABLE
statement, you have some syntactically incorrect INSERT statements, and
the rudimentary beginnings of a second CREATE TABLE statement.

Please repost. Don't forget to include all constraints and properties of
the tables (esp. PRIMARY KEY, FOREIGN KEY and UNIQUE). And if you
include sample data as INSERT statements, then include the expected
result as well.

Best, Hugo
CREATE TABLE [GROSMARG_AUDIT_ADDITION] (
[RUN_DATE] [datetime] NULL ,
[SALES_DIFF] [numeric](19, 6) NULL ,
[COST_DIFF] [numeric](19, 6) NULL ,
[ADD_BSL_SALES] [numeric](18, 0) NULL ,
[ADD_BSL_COST] [numeric](18, 0) NULL ,
[ADD_SALES_DIFF] [numeric](18, 0) NULL ,
[ADD_COST_DIFF] [numeric](18, 0) NULL
) ON [PRIMARY]
GO
INSERT RUN_DATE,datetime,
INSERT SALES_DIFF,numeric(19,6),
INSERT COST_DIFF,numeric(19,6)
INSERT ADD_BSL_SALES,numeric(18,0),
INSERT ADD_BSL_COST,numeric(18,0),
INSERT ADD_SALES_DIFF,numeric(18,0)
INSERT ADD_COST_DIFF,numeric(18,0)

--- Second Table

CREATE TABLE #DUPTOTALS
[Sales]
[Costs]

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)
Sep 2 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Dave | last post by:
I have 2 tables, one with names, and another with addresses, joined by their CIVICID number (unique to the ADDRESSINFO table) in Oracle. I need to update a field in the NAMEINFO table for a...
8
by: Lauren Quantrell | last post by:
In VBA, I constructed the following to update all records in tblmyTable with each records in tblmyTableTEMP having the same UniqueID: UPDATE tblMyTable RIGHT JOIN tblMyTableTEMP ON...
1
by: shottarum | last post by:
I currently have 2 tables as follows: CREATE TABLE . ( mhan8 int, mhac02 varchar(5), mhmot varchar(5), mhupmj int )
16
by: robert | last post by:
been ruminating on the question (mostly in a 390/v7 context) of whether, and if so when, a row update becomes an insert/delete. i assume that there is a threshold on the number of columns of the...
18
by: Bill Smith | last post by:
The initial row is inserted with the colPartNum column containing a valid LIKE pattern, such as (without the single quotes) 'AB%DE'. I want to update the column value with the results of a query...
8
by: Maxi | last post by:
There is a lotto system which picks 21 numbers every day out of 80 numbers. I have a table (name:Lotto) with 22 fields (name:Date,P1,P2....P21) Here is the structure and sample data: ...
0
by: Manish | last post by:
Hey Guys I am using a datagrid to extract information out of SQL Server datbase. The fields extracted are category,week,budget,Last Year,Forecast and Projection. Also i add a calculated column...
16
by: Ian Davies | last post by:
Hello Needing help with a suitable solution. I have extracted records into a table under three columns 'category', 'comment' and share (the category column also holds the index no of the record...
2
by: Miro | last post by:
I will ask the question first then fumble thru trying to explain myself so i dont waste too much of your time. Question / Statement - Every mdb table needs a PrimaryKey ( or maybe an index - i...
0
by: ceevee | last post by:
Hi Everyone, Was hoping you could help me understand what I may be doing wrong. I am trying to update a column of one table from the data in a column of another table. Here are my create...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.