|
Home > Archive > Microsoft SQL Server forum > September 2005 > Update Table Column based on value from another table?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
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 =EF=81=8A
Bryan
CREATE TABLE & #91;GROSMARG_AUDIT_A
DDITION] (
[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(1
9,6),
INSERT COST_DIFF,numeric(19
,6)
INSERT ADD_BSL_SALES,numeri
c(18,0),
INSERT ADD_BSL_COST,numeric
(18,0),
INSERT ADD_SALES_DIFF,numer
ic(18,0)
INSERT ADD_COST_DIFF,numeri
c(18,0)
--- Second Table
CREATE TABLE #DUPTOTALS
[Sales]
[Costs]
| |
| Hugo Kornelis 2005-09-02, 8:23 pm |
| 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 & #91;GROSMARG_AUDIT_A
DDITION] (
> [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(1
9,6),
>INSERT COST_DIFF,numeric(19
,6)
>INSERT ADD_BSL_SALES,numeri
c(18,0),
>INSERT ADD_BSL_COST,numeric
(18,0),
>INSERT ADD_SALES_DIFF,numer
ic(18,0)
>INSERT ADD_COST_DIFF,numeri
c(18,0)
>
>--- Second Table
>
>CREATE TABLE #DUPTOTALS
> [Sales]
> [Costs]
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)
|
|
|
|
|