Update problem

Last Post 14 Apr 2010 09:46 AM by JASBRYDEN. 0 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages Not Resolved
New Member
New Member

14 Apr 2010 09:46 AM

I have two scripts.

The first is to update the table temp_forecast_time with the (qtyshipped-qtyreturned) and the second is to update the table temp_forecast_time with netforecastquantity.

Both scripts giving me the results that I want however I need the both of them to run to update the coloum opensalesforeast.

update temp_forecast_time
set opensalesforecast=(qtyshipped-qtyreturned)
from temp_forecast_time
left join forecast_sales_temp on
forecast_sales_temp.saleslocation=temp_forecast_time.saleslocation and forecast_sales_temp.itemno=temp_forecast_time.itemno and forecast_sales_temp.invoicedate=temp_forecast_time.lastinvoicedate and
temp_forecast_time.invoicedateDATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE()),0))

update temp_forecast_time
set opensalesforecast=netforecastquantity
from temp_forecast_time left join ASB_VSAFCDT on
ASB_VSAFCDT.location=temp_forecast_time.saleslocation and
ASB_VSAFCDT.itemno=temp_forecast_time.itemno and
ASB_VSAFCDT.forecast_date=temp_forecast_time.invoicedate and
temp_forecast_time.invoicedate>DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE()),0))

Both of them works when run separate, but if you run the first script you get the results I want when I run the second script it replace the results of the first.

What to do to prevent that ????

I try adding when opensalesforecast is null, but nothing.

PLEASE HELP !!!!!!!!!
You are not authorized to post a reply.

Acceptable Use Policy