Hi, I am new to Navision and in the job…
I am charged with updating all prices and as far as I have found they are all in the table.
Hopefully somebody has done this earlier
I see in the table there is a lot of prices with no end date.
The job I have to do is:
All items with no Ending Date shall have end date (28.03.2009) .
Insert new price from a txtfile with Starting Date 01.03.2009 and Ending Date 28.02.2010
If the latest changed price has Starting Date older than 01.03.2009 and Item No_ is not in the sourcefile(txtfile) insert new line with copy of the old line but new start/end date and price 10% higher than the latest price.
Here are some preliminaries of an SQL to do this - but I would be very happy if somebody allready has this one solved.
Regards
Update set [Ending Date] = ‘2009-02-28’ where [Ending Date] is null and [Starting Date] <= ‘2008-03-01’
Update prices and in some of the raise with 10% (1.1)
Insert into ([Item No_], [Sales Type], [Sales Code], [Starting Date], [Currency Code], [Variant Code],
[Unit of Measure Code], [Minimum Quantity], [Unit Price], [Price Includes VAT],
[Allow Invoice Disc_], [VAT Bus_ Posting Gr_ (Price)], [Ending Date], [Allow Line Disc_])
Select t1.[Item No_], t1. [Sales Type], t1. [Sales Code], ‘2009-03-01’, t1. [Currency Code], t1. [Variant Code],
t1. [Unit of Measure Code], t1. [Minimum Quantity], t1. [Unit Price] * 1.1, t1. [Price Includes VAT],
t1. [Allow Invoice Disc_], t1. [VAT Bus_ Posting Gr_ (Price)], ‘2010-02-28’, t1. [Allow Line Disc_]
From t1
left join t2 on t1. [Item No_] = t2. [Item No_] and t1.[Sales Type] = t2.[Sales Type]
and t1.[Sales Code] = t2.[Sales Code]
Where t1.[Ending Date] = ‘2009-02-28’ and t2. [Item No_] is null
#primary keyes are expected to be [Item No_], [Sales Type] and [Sales Code]