CREATE PROCEDURE DBO.RecalculateProductPricesFromCurrencyRate @TheProductNumber INT,  @FromDate DATETIME, @FromCurrencyRate FLOAT (53), @ToCurrencyRate FLOAT (53) AS
SET NOCOUNT ON
/*

*/

DECLARE @SystemDate DATETIME
SELECT @SystemDate=CONVERT (DATETIME, SystemDate) FROM System WITH (NOLOCK) WHERE Number=1

IF @FromDate < @SystemDate
  SET @FromDate = @SystemDate

IF @FromCurrencyRate <= 0
  SET @FromCurrencyRate = 100

IF @ToCurrencyRate <= 0
  SET @ToCurrencyRate = 100

UPDATE ProductPrice SET
  AdultPrice1 = dbo.GetConvertedCurrencyValue(AdultPrice1, @FromCurrencyRate, @ToCurrencyRate),
  AdultPrice2 = dbo.GetConvertedCurrencyValue(AdultPrice2, @FromCurrencyRate, @ToCurrencyRate),
  AdultPrice3 = dbo.GetConvertedCurrencyValue(AdultPrice3, @FromCurrencyRate, @ToCurrencyRate),
  AdultPrice4 = dbo.GetConvertedCurrencyValue(AdultPrice4, @FromCurrencyRate, @ToCurrencyRate),
  AdultPrice5 = dbo.GetConvertedCurrencyValue(AdultPrice5, @FromCurrencyRate, @ToCurrencyRate),
  AdultPrice6 = dbo.GetConvertedCurrencyValue(AdultPrice6, @FromCurrencyRate, @ToCurrencyRate),
  AdultPrice7 = dbo.GetConvertedCurrencyValue(AdultPrice7, @FromCurrencyRate, @ToCurrencyRate),
  AdultPrice8 = dbo.GetConvertedCurrencyValue(AdultPrice8, @FromCurrencyRate, @ToCurrencyRate),
  AdultPrice9 = dbo.GetConvertedCurrencyValue(AdultPrice9, @FromCurrencyRate, @ToCurrencyRate),

  Children1Price1 = dbo.GetConvertedCurrencyValue(Children1Price1, @FromCurrencyRate, @ToCurrencyRate),
  Children1Price2 = dbo.GetConvertedCurrencyValue(Children1Price2, @FromCurrencyRate, @ToCurrencyRate),
  Children1Price3 = dbo.GetConvertedCurrencyValue(Children1Price3, @FromCurrencyRate, @ToCurrencyRate),
  Children1Price4 = dbo.GetConvertedCurrencyValue(Children1Price4, @FromCurrencyRate, @ToCurrencyRate),
  Children1Price5 = dbo.GetConvertedCurrencyValue(Children1Price5, @FromCurrencyRate, @ToCurrencyRate),
  Children1Price6 = dbo.GetConvertedCurrencyValue(Children1Price6, @FromCurrencyRate, @ToCurrencyRate),
  Children1Price7 = dbo.GetConvertedCurrencyValue(Children1Price7, @FromCurrencyRate, @ToCurrencyRate),
  Children1Price8 = dbo.GetConvertedCurrencyValue(Children1Price8, @FromCurrencyRate, @ToCurrencyRate),
  Children1Price9 = dbo.GetConvertedCurrencyValue(Children1Price9, @FromCurrencyRate, @ToCurrencyRate),

  Children2Price1 = dbo.GetConvertedCurrencyValue(Children2Price1, @FromCurrencyRate, @ToCurrencyRate),
  Children2Price2 = dbo.GetConvertedCurrencyValue(Children2Price2, @FromCurrencyRate, @ToCurrencyRate),
  Children2Price3 = dbo.GetConvertedCurrencyValue(Children2Price3, @FromCurrencyRate, @ToCurrencyRate),
  Children2Price4 = dbo.GetConvertedCurrencyValue(Children2Price4, @FromCurrencyRate, @ToCurrencyRate),
  Children2Price5 = dbo.GetConvertedCurrencyValue(Children2Price5, @FromCurrencyRate, @ToCurrencyRate),
  Children2Price6 = dbo.GetConvertedCurrencyValue(Children2Price6, @FromCurrencyRate, @ToCurrencyRate),
  Children2Price7 = dbo.GetConvertedCurrencyValue(Children2Price7, @FromCurrencyRate, @ToCurrencyRate),
  Children2Price8 = dbo.GetConvertedCurrencyValue(Children2Price8, @FromCurrencyRate, @ToCurrencyRate),
  Children2Price9 = dbo.GetConvertedCurrencyValue(Children2Price9, @FromCurrencyRate, @ToCurrencyRate)
WHERE ProductNumber = @TheProductNumber AND (DateStamp >= CONVERT(CHAR, @FromDate, 112))

