By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,939 Members | 1,600 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,939 IT Pros & Developers. It's quick & easy.

Update Table Column based on value from another table?

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.