CREATE FUNCTION dbo.GetVatPercent (@VATValueNumber tinyint)  
RETURNS REAL AS  
BEGIN 
-- nb20040309: Oprettet 

Declare @VatValueWareText varchar(8)

if (@VATValueNumber=0)
  Select @VatValueWareText = KeyValue from HotelSetUp WITH (NOLOCK) Where  SearchKey='VATValue0' 
else
if (@VATValueNumber=1)
  Select @VatValueWareText = KeyValue from HotelSetUp WITH (NOLOCK) Where  SearchKey='VATValue1' 
else
if (@VATValueNumber=2)
  Select @VatValueWareText = KeyValue from HotelSetUp WITH (NOLOCK) Where  SearchKey='VATValue2' 
else
if (@VATValueNumber=3)
  Select @VatValueWareText = KeyValue from HotelSetUp WITH (NOLOCK) Where  SearchKey='VATValue3' 
else
if (@VATValueNumber=4)
  Select @VatValueWareText = KeyValue from HotelSetUp WITH (NOLOCK) Where  SearchKey='VATValue4' 
else
if (@VATValueNumber=5)
  Select @VatValueWareText = KeyValue from HotelSetUp WITH (NOLOCK) Where  SearchKey='VATValue5' 

if (charindex(',',@VatValueWareText)>0)
  SET @VatValueWareText = STUFF(@VatValueWareText, charindex(',',@VatValueWareText) ,1, '.')
      
RETURN (CONVERT(FLOAT, @VatValueWareText))

END

