Question
You have a SQL query that combines customer data and order data. The query includes calculated columns.
You need to create a database object that would allow other users to rerun the same SQL query.
What should you create?
- A. an index
- B. a view Correct
- C. a scalar function
- D. a table
Explanation
A view is a virtual table defined by a stored SELECT query; it can join customer and order data and include calculated columns, and other users simply query the view to rerun it. An index only speeds up data access, a scalar function returns a single value rather than a result set, and a table would store a static copy of the data instead of rerunning the query.