I have quite a few SP's that need changing to accomodate exchange rate calculations. These SP's are run possibly 1000's of times each day so they need to be as fast as possible. Basically data comes from several shops up to the HQ and the data gets inserted.
Now, 1 of those stores is in a foreign country but the HQ would like all the data in the same home currency, so when the data from that specific store comes up it needs converting. I've got no problem with this but this conversion would be the exception rather than the rule and i'm just wondering what would be fastest:
1. Select the exchange rate - if it's NULL (therefore no conversion required) set it to zero.
2 In the insert do like the following (there will be more than 1 column that need changing BTW):
INSERT INTO
([Column1])
VALUES
(CASE WHEN @ExchangeRate = 0 THEN @SalesTax ELSE (@SalesTax / @ExchangeRate) END)
OR
1. Select the exchange rate - if it's NULL (therefore no conversion required) set it to 1.
2 In the insert do like the following (there will be more than 1 column that need changing BTW):
INSERT INTO
([Column1])
VALUES
((@SalesTax / @ExchangeRate))
What's quicker for SQL to evaluate given that there are 5 shops sending data and only 1 that will need converting?
TIA
Clegg
Now, 1 of those stores is in a foreign country but the HQ would like all the data in the same home currency, so when the data from that specific store comes up it needs converting. I've got no problem with this but this conversion would be the exception rather than the rule and i'm just wondering what would be fastest:
1. Select the exchange rate - if it's NULL (therefore no conversion required) set it to zero.
2 In the insert do like the following (there will be more than 1 column that need changing BTW):
INSERT INTO
([Column1])
VALUES
(CASE WHEN @ExchangeRate = 0 THEN @SalesTax ELSE (@SalesTax / @ExchangeRate) END)
OR
1. Select the exchange rate - if it's NULL (therefore no conversion required) set it to 1.
2 In the insert do like the following (there will be more than 1 column that need changing BTW):
INSERT INTO
([Column1])
VALUES
((@SalesTax / @ExchangeRate))
What's quicker for SQL to evaluate given that there are 5 shops sending data and only 1 that will need converting?
TIA
Clegg