0

Is there a way to preprocess the data returned from SQL Server in a select statement at all?

Scenario, we need to save all money figures into our database as the default exchange rate. i.e. If money figure entered in China, it will get resolved and saved as USD with the chinese exchange rate assigned to it. I can utilize triggers to automate this at the db level.

When we perform a select from this table i'm wanting to return the figure as the Chinese amount which will be Money field * exchange rate. Is this possible at all?

Any advice? Im hoping we can do this at the db layer as we are working with legacy software.

Thanks

2 Answers 2

1

I would suggest using a view for this:

create view v_table as
    select t.*,
           (t.MoneyFigure / t.ExchangeRate) as LocalCurrencyAmount
    from table t;

In SQL Server, you can also do this by adding a computed column to the table:

alter table
    add LocalCurrencyAmount as (t.MoneyFigure / t.ExchangeRate);
Sign up to request clarification or add additional context in comments.

Comments

0

There is no pre-process layer in SQL Server.

One way around it (not the best in some ways though) is to rename the tables to a new name and create views for those tables that have the same names as the original tables. This way you will be able to manipulate the data in the views.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.