Chapter 15 Flashcards

1
Q

Which of the following statements calls the stored procedure and passes the values ‘2019-10-01’ and 122 to its input parameters?

CREATE PROC spInvoiceTotal1
       @DateVar smalldatetime,
       @VendorID int
AS
SELECT SUM(InvoiceTotal)
FROM Invoices
WHERE VendorID = @VendorID AND InvoiceDate >= @DateVar;
A

EXEC spInvoiceTotal1 @VendorID = 122, @DateVar = ‘2019-10-01’;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Stored procedures execute faster than an equivalent SQL script because stored procedures are what?

A

precompiled

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Data validation is the process of

A

preventing errors due to invalid data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Before you can pass a table to a stored procedure or a function as a parameter, which statement do you use to create a user-defined table type?

A

CREATE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

You typically use the return value of a stored procedure to

A

indicate to the calling program whether the stored procedure completed successfully

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Which of the following statements returns the value of a variable named @InvoiceCount?

A

RETURN @InvoiceCount;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which statement can you use to manually raise an error within a stored procedure?

A

THROW

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

If you delete a stored procedure, function, or trigger and then create it again

A

you delete the security permissions assigned to the object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Which of the following statements calls the following stored procedure, passes the value ‘2019-10-01’ to its input parameter, and stores the value of its output parameter in a variable named @MyInvoiceTotal?

CREATE PROC spInvoiceTotal2
       @DateVar smalldatetime,
       @InvoiceTotal money OUTPUT
AS
SELECT @InvoiceTotal = SUM(InvoiceTotal)
FROM Invoices
WHERE InvoiceDate >= @DateVar;

(Assume that the @MyInvoiceTotal variable has already been declared, and pass the parameters by position.)

A

EXEC spInvoiceTotal2 ‘2019-10-01’, @MyInvoiceTotal OUTPUT;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

When passing a list of parameters to a stored procedure by name, you can omit optional parameters by

A

omitting the parameter name and value from the list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

If you want to prevent users from examining the SQL code that defines a procedure, function, or trigger, you code the CREATE statement with the ________________ option

A

ENCRYPTION

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

To make a parameter for a stored procedure optional, what do you assign to it?

A

a default value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Which of the following statements executes a stored procedure named spInvoiceCount and stores its return value in a variable named @InvoiceCount?
(Assume that the @InvoiceCount variable has already been declared and that the stored procedure doesn’t accept any parameters.)

A

EXEC @InvoiceCount = spInvoiceCount;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

System stored procedures

A

perform standard tasks on the current database

are stored in the Master database

can change with each version of SQL Server

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Which keyword can you use to pass a parameter from a stored procedure back to the calling program?

A

OUTPUT

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

When you use Transact-SQL, you can store procedural code in

A

scripts

stored procedures

user-defined functions