Unix Technical Forum

Update Table Column based on value from another table?

This is a discussion on Update Table Column based on value from another table? within the SQL Server forums, part of the Microsoft SQL Server category; --> Hi, I have two tables. I want to update two columns in my first table, [ADD_BSL_SALES] and [ADD_BSL_COST] with ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-29-2008, 08:55 AM
Bryan
 
Posts: n/a
Default 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]

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-29-2008, 08:56 AM
Hugo Kornelis
 
Posts: n/a
Default Re: Update Table Column based on value from another table?

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)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 08:05 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com