Extra notes 3 Flashcards

1
Q

How can you use a symmetric key and certificate to protect a column?

A

OPEN SYMMETRIC KEY KeyName
DECRYPTION BY CERTIFICATE CertificateName
UPDATE TableName
SET Column = EncryptByKey(Key_GUID(‘KeyName’), @VarWithData, 1, HashBytes(‘SHA1’, CONVERT(varbinary, ColumnName)))

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

Can a SCALAR User Defined Function support using a table variable?

A

Yes

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

What monitoring application would you use to view I/O subsystem performance issues (highest stall times)?

A

Activity Monitor

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

What can you suspect when locks are taken in a database while using READ_COMMITTED_SNAPSHOT?

A

TempDB has filled up and when that happens locks are taken on the database level

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

How do you insert a connection string into a query?

A

Select Col1, Col2

FROM Table OPENDATASOURCE(ConnectionString)

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

Which System View shows All Unused Indexes?

A

sys.dm_db_index_usage_stats

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

Which System View shows all indexes that must be fragmented?

A

sys.dm_db_index_physical_stats

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

Which System View shows all indexes that have page splits?

A

sys.dm_db_index_operational_stats

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

At what point do statistics get generated automatically?

A
  1. When you populate an empty table;
  2. When a table with fewer than 500 rows doubles in size;
  3. When a table with more than 500 rows grows by 500 rows plus 20% of the current row count
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What tool do you use to analyze a deadlock graph?

A

SSMS

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

What two types of data compression are available for rowstore tables and indexes?

A

Row and Page

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

How does SQL Server produce the result set for a non-indexed view?

A

The rows and columns of data originate from tables referenced in the query defining the view and they are produced dynamically when the view is referenced.

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

What correctly defines indexed columns and included columns?

A

Indexed columns form the key of the index, and included columns are non-key columns used to improve query coverage

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

Why is NEWID a nondeterministic function?

A

NEWID returns a unique identifier and a different result.

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

You possess a database in an availability group with in-memory tables. Users express that sometimes they see the results of updates and sometimes the results of updates are unavailable. What is the most likely explanation?

A

The application uses delayed durable transactions and the changes have not yet replicated to the secondary replicas.

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

How might you determine an I/O related memory problem in a SQL Server instance?

A

Use the Dynamic Management View (DMV) sys.dm_os_wait_stats and locate excessive PAGEIOLATCH wait types.

17
Q

How can you use a foreign key with a calculated column?

A

You have to use the PERSISTED keyword when creating the column.

18
Q

Can you alter a calculated column?

A

No, in order to change a calculated column you have to drop it and recreate it.

19
Q

What kind of user can you grant access to but that cannot be used for authentication?

A

A database user without a login.

20
Q

Where should you use a database user without a login?

A

When you need to authenticate applications at the database level without hardcoding passwords.

21
Q

You have a table trigger that makes sure that data fits within given rules, how can you remove it?

A

Use constraints, either Foreign Key or Check.

22
Q

What can you use to replace of a trigger that keeps track of changes?

A

Auditing by using OUTPUT INTO a table from an insert statement:

INSERT INTO table OUTPUT inserted.val1, inserted.val2 into OutputAuditTable values (val1Value, val2Value)

23
Q

What is cardinality?

A

Number of rows in a query result

24
Q

What are statistics used for?

A

Used by query optimizer to Create query plans that improve query performance.

25
Q

What are the required steps for creating an indexed view?

A
  1. Verify the SET options are correct for all existing tables that will be referenced in the view.
  2. Verify that the SET options for the session are set correctly before you create any tables and the view.
  3. Verify that the view definition is deterministic.
  4. Create the view by using the WITH SCHEMABINDING option.
  5. Create the unique clustered index on the view.