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 ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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] |
| ||||
| 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) |