CREATE FUNCTION dbo.getProductCurrencyCode(@ProductNumber int)
RETURNS int
AS
BEGIN
    DECLARE @r int
    SELECT @r = ProductCurrencyCode FROM ProductExtended WITH (NOLOCK) WHERE FK_ProductNumber = @ProductNumber
    RETURN @r
END
GO

ALTER TABLE dbo.Products DROP CONSTRAINT FK_Products_Countries
ALTER TABLE dbo.Products DROP COLUMN CurrencyNumber
GO

ALTER TABLE dbo.Products ADD CurrencyNumber AS dbo.GetProductCurrencyCode([ProductNumber])
GO  
