exam questions

Exam 70-761 All Questions

View all questions & answers for the 70-761 exam

Exam 70-761 topic 1 question 51 discussion

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

HOTSPOT -
Note: This question is part of a series of questions that use the same scenario. For your convenience, the scenario is repeated in each question. Each question presents a different goal and answer choices, but the text of the scenario is exactly the same in each question in this series.
You are developing a database to track customer orders. The database contains the following tables: Sales.Customers, Sales.Orders, and Sales.OrderLines.
The following table describes the columns in Sales.Customers.

The following table describes the columns in Sales.Orders.

The following table describes the columns in Sales.OrderLines.

You need to create a database object that calculates the total price of an order including the sales tax. The database object must meet the following requirements:
✑ Reduce the compilation cost of Transact-SQL code by caching the plans and reusing them for repeated execution.
✑ Return a value.
✑ Be callable from a SELECT statement.
How should you complete the Transact-SQL statements? To answer, select the appropriate Transact-SQL segments in the answer area.
Hot Area:

Show Suggested Answer Hide Answer
Suggested Answer:
Box 1: FUNCTION -
To be able to return a value we should use a scalar function.
CREATE FUNCTION creates a user-defined function in SQL Server and Azure SQL Database. The return value can either be a scalar (single) value or a table.
Box 2: RETURNS decimal(18,2)
Use the same data format as used in the UnitPrice column.

Box 3: BEGIN -
Transact-SQL Scalar Function Syntax include the BEGIN ..END construct.
CREATE [ OR ALTER ] FUNCTION [ schema_name. ] function_name
( [ { @parameter_name [ AS ][ type_schema_name. ] parameter_data_type
[ = default ] [ READONLY ] }
[ ,...n ]
]
)

RETURNSreturn_data_type -
[ WITH <function_option> [ ,...n ] ]
[ AS ]

BEGIN -
function_body

RETURN scalar_expression -

END -
[ ; ]
Box 4: @OrderPrice * @CalculatedTaxRate
Calculate the price including tax.

Box 5: END -
Transact-SQL Scalar Function Syntax include theBEGIN ..END construct.
References:
https://msdn.microsoft.com/en-us/library/ms186755.aspx

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
Angelcr
4 years, 5 months ago
Correct
upvoted 1 times
...
lh2607
4 years, 6 months ago
Correctimundo
upvoted 2 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 ...