exam questions

Exam 70-762 All Questions

View all questions & answers for the 70-762 exam

Exam 70-762 topic 1 question 46 discussion

Actual exam question from Microsoft's 70-762
Question #: 46
Topic #: 1
[All 70-762 Questions]

You have a view that includes an aggregate.
You must be able to change the values of columns in the view. The changes must be reflected in the tables that the view uses.
You need to ensure that you can update the view.
What should you create?

  • A. table-valued function
  • B. a schema-bound view
  • C. a partitioned view
  • D. a DML trigger
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️
When you use the SchemaBinding keyword while creating a view or function you bind the structure of any underlying tables or views. Itmeans that as long as that schemabound object exists as a schemabound object (ie you don't remove schemabinding) you are limited in changes that can be made to the tables or views that it refers to.
References:
https://sqlstudies.com/2014/08/06/schemabinding-what-why/

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
LilahM
Highly Voted 5 years, 8 months ago
Wouldn't a dml (instead of) trigger be the better choice here, assuming that the view references several tables?
upvoted 32 times
Hoglet
4 years, 4 months ago
Yes, you would create an INSREAD OF trigger for the view You would not be able to updating via the view because of the aggregate contained in it
upvoted 1 times
...
...
SzalonyZielonyRobak
Highly Voted 5 years, 2 months ago
D - DML Trigger (Instead of). If you have an aggreate in view you need some complex logic to calculate how to change tables that are a base a view (that the view is referencing).
upvoted 8 times
...
UsefJuan
Most Recent 4 years, 6 months ago
this question doesnt make sense. here is the original question : You have a view that includes an aggregate. You must be able to change the values of columns in the view. The changes must be reflected in the tables that the view uses. You need to ensure that you can update the view. What should you create? A. a nonclustered index B. a schema-bound view C. a stored procedure D. an INSTEAD OF trigger and the answer was D
upvoted 2 times
Hoglet
4 years, 4 months ago
Correct. An INSTEAD OF Trigger fires when a DML statement is issued, i.e. it's a DML Trigger
upvoted 1 times
...
...
SoupDJ
4 years, 6 months ago
I agree with Andy - schema-binding limits structural changes to the underlying tables for the view - which is not what this question seems to be about. Because there is an aggregate column, the other columns may represent group by columns - so a change in any of their values would necessitate a change in the aggregate column (and potentially other columns as well). A trigger on the view would be a way to clean this up and keep the view rows internally consistent.
upvoted 3 times
...
Andy7622
4 years, 7 months ago
schema bounding relates to structural changes in the underlying tables to the changing on values if I understand it correctly looks like B isn't an option
upvoted 2 times
...
New_user
5 years, 4 months ago
C is also right answer. Partitioned views allow to modify the data in tables with several restrictions. https://docs.microsoft.com/en-gb/sql/t-sql/statements/create-view-transact-sql?view=sql-server-ver15
upvoted 1 times
JohnFan
5 years, 2 months ago
A partitioned view is a view that is based on a query that uses a UNION ALL set operator to treat multiple tables as one. Before the feature of partitioning tables and indexes was created, it was the primary way to give an administrator the ability to manage multiple “slices” of a table as different physical resources. The feature still exists, both for backward compatibility (since partitioning is the typical best way to implement partitioning since 2005), and to enable a VIEW object to work across multiple independent federated SQL Servers. Generally, the place where this feature is still the best practice is a case such as having two or more servers located in different corporate locations. Each location might have a copy of their data, and then a view is created that lets you treat the table as one on the local server.
upvoted 1 times
...
Hoglet
4 years, 4 months ago
However an updatable view must meet certain conditions, and an updatable partitioned view has further conditions it must meet. From the manual we can see that the view as described cannot be an updateable view due to the aggregated column in it. "The columns being modified in the view must directly reference the underlying data in the table columns. The columns cannot be derived in any other way, such as through the following: An aggregate function: AVG, COUNT, SUM, MIN, MAX, GROUPING, STDEV, STDEVP, VAR, and VARP" Because of this we have to use an INSTEAD OF Trigger (DML trigger)
upvoted 2 times
...
...
RavenVStar
5 years, 4 months ago
I agree. The first clue is that the view already exists and that you need to update data, not create the view so DML trigger makes more sense.
upvoted 6 times
...
Dieter
5 years, 8 months ago
exactly, in particular as the view has an aggregate. I agree
upvoted 7 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago