PrepAway - Latest Free Exam Questions & Answers

What Transact-SQL statements would accomplish this task?

You work as a database developer at ABC.com. ABC.com has a SQL Server 2012 database
named SalesDB that has a table named Inventory.
The Inventory table has three columns named ProductID, InStore and InWarehouse. The
ProductID column is the primary key and is linked to the Products table. The InStore column
stores the quantity of a product that is held at ABC.com’s retail shop, while the InWarehouse
column stores the quantity of a product that is held at ABC.com’s warehouse.
You need to add a computed column that stores the total number of a product that ABC.com has.
What Transact-SQL statements would accomplish this task?

PrepAway - Latest Free Exam Questions & Answers

A.
ALTER TABLE Inventory
ADD TotalProducts AS (InStore + InWarehouse) PERSISTED

B.
ALTER TABLE Inventory
ADD TotalProducts int SPARSE NOT NULL

C.
ALTER TABLE Inventory
ADD TotalProducts AS SUM (ALL) OVER (GROUP BY InStore, InWarehouse) PERSISTED

D.
DROP TABLE Inventory
GO
CREATE TABLE Inventory
(
ProductID int NOT NULL PRIMARY KEY,
InStore int NOT NULL,
InWarehouse int NOT NULL,
TotalProducts AS SUM (InStore, InWarehouse) PERSISTED
)

Explanation:

Ref: http://www.kodyaz.com/articles/sql-server-computed-column-calculated-column-sample.aspx

One Comment on “What Transact-SQL statements would accomplish this task?


Leave a Reply