• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/449

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

449 Cards in this Set

  • Front
  • Back
What is a principal?
The means by which you authenticate and are identified within an instance or database.
What are the 5 types of logins in SQL Server 2008?
Standard SQL Server login

Windows login

Windows group

Certificate

Asymmetric key
How does SQL Server map a windows user or group to a Standard SQL Server login?
SQL stores the name of the login or group along with the corresponding security identifier (SID); when a user logs in to the instance using windows credentials, SQL makes a call to the windows security application programming interface to validate the account, retrieve the SID and then compare the SID to those stored in the master database.
What do SQL Server logins mapped to certificates or asymmetric keys lack?
A means to authenticate. Logins mapped to certificates and asymmetric keys are used internally as a security container.
What is the syntax to create a login?
CREATE LOGIN loginName { WITH <option_list1> / FROM <sources> }

<option_list1> ::=
PASSWORD = { 'password' / hashed_password HASHED } [ MUST_CHANGE ]
[ , <option_list2> [ ,... ] ]

<option_list2> ::=

SID = sid

/ DEFAULT_DATABASE = database
/ DEFAULT_LANGUAGE = language
/ CHECK_EXPIRATION = { ON / OFF}
/ CHECK_POLICY = { ON / OFF}
/ CREDENTIAL = credential_name

<sources> ::=
WINDOWS [ WITH <windows_options> [ ,... ] ]
/ CERTIFICATE certname
/ ASYMMETRIC KEY asym_key_name

<windows_options> ::=
DEFAULT_DATABASE = database
/ DEFAULT_LANGUAGE = language
What is the CHECK_POLICY option in creating logins?
It is the default option; when enabled, SQL server enforces the windows password policy settings when you create a SQL Server login.
What is the CHECK_EXPIRATION option in creating logins?
It is used to prevent brute force attacks against a login. When enabled, each time the login is used to authenticate to an instance, SQL Server checks whether the password has expired and change the password if necessary.
Why is the sa account a target for brute force attacks.
Unlike other accounts, the sa account cannot be locked out due to failed login attempts. You can rename the SA account as an alternative.
How can you prevent access by user/users without revoking permissions?
You can disable the account:

ALTER LOGIN <loginname> DISABLE
What are the instance level roles that ship with SQL; can you change permissions on them?
-- bulkadmin - Administer BCP and Bulk Insert operations

-- dbcreator - Create databases

-- diskadmin - Manage disk resources

-- processadmin - Manage connections and start or pause an instance

-- securityadmin - Create, alter, and drop logins, but cannot change passwords

-- serveradmin - Perform the same actions as diskadmin and processadmin, plus manage endpoints, change instance settings, and shut down the instance

-- setupadmin - Manage linked servers

-- sysadmin - Perform any action within the instance. Members cannot be prevented from accessing any object or performing any action.

No, you cannot change permissions on them.
How do you grant access to a database?
By adding a login to the database as a user by executing the CREATE USER command.
What is the syntax for the CREATE USER command?
CREATE USER user_name

[ { { FOR / FROM }
{ LOGIN login_name
/ CERTIFICATE cert_name
/ ASYMMETRIC KEY asym_key_name}
/ WITHOUT LOGIN ]
[ WITH DEFAULT_SCHEMA = schema_name ]
What is a loginless user?
A user in the database that is not associated to a login. Loginless users were added to replace application roles. Users still authenticate to the instance using their own credentials. The user‚ login needs access to the database. After SQL Server changes the user‚ context to the database, the user impersonates the loginless user to gain necessary permissions. Because the user is authenticating to the instance using his or her own credentials, SQL Server can still audit activity to an individual login even though the login is impersonating a loginless user.
What are the fixed roles at the database level?
-- db_accessadmin - Add or remove users in the database

-- db_backupoperator - Back up the database but cannot restore a database or view any information in the database

-- db_datareader - Issue SELECT against all tables, views, and functions within the database

-- db_datawriter - Issue INSERT, UPDATE, DELETE, and MERGE against all tables within the database. Members of this role must also be members of the db_datareader role.

-- db_ddladmin - Execute data definition language (DDL) statements

-- db_denydatareader - Prevent SELECT against all tables, views, and functions within the database

-- db_denydatawriter - Prevent INSERT, UPDATE, DELETE, and MERGE against all tables within the database

-- db_owner - Owner of the database that has full control over the database and all objects contained within the database

-- db_securityadmin - Manage the membership of roles and associated permissions, but cannot manage membership for the db_owner role

--public - Default group in every database that all users belong to
Which logins cannot be used to authenticate to an instance?
You cannot use logins that are mapped to a certificate or asymmetric key to authenticate to an instance.
What are the only objects directly owned by a database user?
schemas
If you need to allow a user to view metadata in a database, what command do you execute?
GRANT VIEW DEFINITION TO <user>
What command can you execute to allow a login to view metadata on any object?
GRANT VIEW ANY DEFINITION TO <user>
In order for a login to see execution statistics, such as sys.dm_exec_requests, what command do you need to execute?
GRANT VIEW SERVER STATE TO <user>
How do you accomplish impersonation?
{ EXEC / EXECUTE ] AS <context_specification>
<context_specification>::=
{ LOGIN / USER } = 'name'
[ WITH { NO REVERT / COOKIE INTO @varbinary_variable } ]
/ CALLER
What type of key is the Service Master Key?
It is a symmetric key generated from the local machine key and encrypted using the SQL Server service account by the Windows Data Protection API.
What statement is used to create a Database Master Key?
CREATE MASTER KEY ENCRYPTION BY PASSWORD = '<Strong password'>
How is the database master key encrypted?
Using Triple DES and the user-supplied password. A copy is also encrypted using the service master key such that automatic decryption can be accomplished within the instance.
What is the database master key used to protect?
Any certificates, symmetric keys or asymmetric keys that are stored in the db.
When you make a request to decrypt data, what happens?
The service master key is used to decrypt the database master key, that is used to decrypt a certificate, symmetric key or assymmetric key, and in turn is used to decrypt the data.
To restore and be able to decrypt data successfully, you must be able to backup the db master key and then regenerate the db master key on another instance. What commands do you use to perform this?
OPEN MASTER KEY

BACKUP MASTER KEY

RESTORE MASTER KEY

CLOSE MASTER KEY
What standard are certificates based on?
X.509
What is the syntax for creating a self-signed certificate in SQL Server?
CREATE CERTIFICATE certificate_name [ AUTHORIZATION user_name ]

{ FROM <existing_keys> / <generate_new_keys> }
[ ACTIVE FOR BEGIN_DIALOG = { ON / OFF } ]

<existing_keys> ::=
ASSEMBLY assembly_name / {
[ EXECUTABLE ] FILE = 'path_to_file'
[ WITH PRIVATE KEY ( <private_key_options> ) ] }

<generate_new_keys> ::=
[ ENCRYPTION BY PASSWORD = 'password']
WITH SUBJECT = 'certificate_subject_name'
[ , <date_options> [ ,...n ] ]

<private_key_options> ::=
FILE = 'path_to_private_key'
[ , DECRYPTION BY PASSWORD = 'password' ]
[ , ENCRYPTION BY PASSWORD = 'password' ]

<date_options> ::=
START_DATE = 'mm/dd/yyyy' / EXPIRY_DATE = 'mm/dd/yyyy'
What is the purpose of a signature?
It allows you to elevate a user's permission but to provide a restriction such that the elevation occurs only when the user is executing a specific piece of code.
What can you add a signature to?
stored procedures

functions

triggers

assemblies
What is the process to sign code digitally?
1. Create a database master key.

2. Create a certificate in the database.

3. Create a user mapped to the certificate.

4. Assign permissions on an object or objects to the user.

5. Execute ADD SIGNATURE on a module by the certificate.
How are principals, securables, and permissions related?
You can GRANT, REVOKE, or DENY permissions ON a securable TO a principal.
What is an ownership chain, and how can you have a broken ownership chain?
An ownership chain applies to objects that reference other objects within a database. The owner of the schema that contains the object is considered the owner of the object. SQL Server checks permissions for the first object that you access, as well as each time the owner changes within the calling stack. The chain of object owners within a calling stack is called an ownership chain. You have a broken ownership chain when the object owner changes within a calling stack and you have not been granted sufficient permissions to continue accessing objects within the call stack.
What principals can you not impersonate?
Principals that have been mapped to a certificate or asymmetric key.
What are DDL triggers?
They allow you to trap and respond to login events.
What is the syntax for creating a DDL trigger?
CREATE TRIGGER trigger_name

ON { ALL SERVER / DATABASE }
[ WITH <ddl_trigger_option> [ ,...n ] ]
{ FOR / AFTER } { event_type / event_group } [ ,...n ]
AS { sql_statement [ ; ] [ ,...n ] /
EXTERNAL NAME < method specifier > [ ; ] }

Trigger on a LOGON event (Logon Trigger)

CREATE TRIGGER trigger_name
ON ALL SERVER
[ WITH <logon_trigger_option> [ ,...n ] ]
{ FOR / AFTER } LOGON
AS { sql_statement [ ; ] [ ,...n ] /
EXTERNAL NAME < method specifier > [ ; ] }
Can you prevent an ALTER DATABASE with a DDL trigger?
No, ALTER DATABASE executes outside the scope of a transaction and cannot be rolled back with a DDL trigger. A DDL trigger can only audit it.
How are DDL triggers related to the Policy-based management framework?
The Policy-based management framework creates DDL triggers for all policies that you configure to prevent an out of compliance situation.
What is the syntax for creating a server audit object?
CREATE SERVER AUDIT audit_name

TO { [ FILE (<file_options> [, ...n]) ] /
APPLICATION_LOG / SECURITY_LOG }
[ WITH ( <audit_options> [, ...n] ) ] }[ ; ]

<file_options>::=
{FILEPATH = 'os_file_path'
[, MAXSIZE = { max_size { MB / GB / TB } / UNLIMITED } ]
[, MAX_ROLLOVER_FILES = integer ]
[, RESERVE_DISK_SPACE = { ON / OFF } ] }

<audit_options>::=
{ [ QUEUE_DELAY = integer ]
[, ON_FAILURE = { CONTINUE / SHUTDOWN } ]
[, AUDIT_GUID = uniqueidentifier ]}
What does QUEUE_DELAY control for audit objects?
Whether messages are sent synchronously or asynchronously; when set to 0, audit records are sent to the audit log synchronously with the transaction.
What does the On_FAILURE action control in an audit object?
It controls how the instance behaves if audit records cannot be written. The default option is CONTINUE, which allows the instance to continue running and processing transactions. If you specify a value of SHUTDOWN, if the audit record cannot be written to the log within the specified QUEUE_DELAY interval, the instance is shut down.
What is C2 auditing?
A U.S. Department of Defense audit specification.
What can columns be encrypted using?
hash

passphrase

symmetric key

asymmetric key

certificate

Symmetric keys provide best balance between performance and securing data. Asymmetric keys and certificates provide strongest encryption.
Can an encrypted column be indexed? Searched?
No. No.
What is an example of a one-way encryption algorithm (can only encrypt, not decrypt)?
Hash
How does SQL Server handle passwords?
SQL Server uses an MD5 hash to handle passwords. When a password is specified for an object, SQL Server applies an MD5 hash and stores the hash value. When you specify a password to access an object, the password is hashed using the same MD5 hash, the hashed password is transmitted in a secure channel, and the hash value transmitted is compared to the hash value stored. Even an administrator who is running a trace cannot access the password.
What are the 5 hash algorithms allowed by SQL Server?
SHA

SHA1

MD2

MD4

MD5
Why is it not a good idea to use a hash algorithm to encrypt birth dates, salaries or credit card numbers?
Hash algorithms are vulnerable to brute force attacks. If the range of values that you are seeking to encrypt is small, an attacker can easily generate all the possible hashes for the range of possible values. After generating these hashes, the attacker needs to compare the hash values to find a match and thus reverse-engineer your data.
How can you increase the complexity of a hash?
By salting - adding a string of one more characters to the value before hashing.
What keys utilize a single key for both encryption and decryption?
symmetric
Which key is generated by a key server and cannot be backed up or moved from one system to another?
asymmetric
What does Transparent Data Encryption (TDE) provide?
TDE is used to encrypt data at rest. The contents of the data and transaction log, along with any backups, are encrypted by the engine. TDE works by using an encryption key stored within the database boot record. The TDE key is encrypted by using a certificate within the master database.
What is the process of implementing TDE on a database?
1. Create a database master key in the master database.

2. Create a certificate in the master database.

3. Create a database encryption key in the target database using the certificate in the master database.

4. Alter the database and enable encryption.
Why should you backup the certificate used for TDE and store the backup in a safe place?
After you encrypt it, you cannot access your data without the certificate.
What are the items that you can capture data for with System Monitor?
Objects, counters and counter instances.
What types of data can system monitor capture?
Numeric data for performance counters that are defined for hardware or software components.
What are the three counters that, by themselves, indicate a system problem?
System:Processor Queue Length, Network Interface:Output Queue Length, and Physical Disk:Avg. Disk Queue Length.
What is the purpose of the Blank Profiler Trace Template?
An empty trace; allows you to create an entire trace from scratch.
What is the purpose of the SP_Counts Profiler Trace Template?
Captures each stored procedure executed so that you can determine

How many of each procedure is being executed.
What is the purpose of the Standard Profiler Trace Template?
The most common template to start with; captures stored procedure and ad hoc SQL being executed along with performance statistics for each procedure and batch. Every login and logout is also captured.
What is the purpose of the TSQL Profiler Trace Template?
Captures a list of all the stored procedures and ad hoc SQL batches that are executed, but does not include any performance statistics.
What is the purpose of the TSQL_Duration Profiler Trace Template?
Captures the duration of every stored procedure and ad hoc SQL batch that is executed.
What is the purpose of the TSQL_Grouped Profiler Trace Template?
Captures every login and logout along with the stored procedures and ad hoc SQL batches that are executed. Includes information to identify the application and user executing the request, but does not include any performance data.
What is the purpose of the TSQL_Locks Profiler Trace Template?
Captures blocking and deadlock information such as blocked processes, deadlock chains, deadlock graphs, lock escalation, and lock timeouts. This template also captures every stored procedure, each command within a stored procedure, and every ad hoc SQL request.
What is the purpose of the TSQL_Replay Profiler Trace Template?
Captures the stored procedures and ad hoc SQL batches executed against the instance in a format that allows you to replay the trace against a test system. This template is commonly used to perform load and regression tests.
What is the purpose of the TSQL_SPs Profiler Trace Template?
Captures performance data for all ad hoc SQL batches, stored procedures, and each statement inside a stored procedure. Every login and logout is also captured.
What is the purpose of the Tuning Profiler Trace Template?
Captures basic performance information for ad hoc SQL batches, stored procedures, and each statement inside a stored procedure.
What is the cause of enabling file rollover for a trace file?
After the file reaches the upper size limit specified, the file closes and a new file is opened.
Why should you never log trace events to the same instance for which you are capturing events?
You can possibly overwhelm the server; the best solution is to log trace events to a file and then later import the file into the server for analysis.
What is the purpose of the Broker SQL Trace Event Group?
13 events for Service Broker messages, queues, and conversations.
What is the purpose of the CLR SQL Trace Event Group?
1 event for the loading of a Common Language Runtime (CLR) assembly.
What is the purpose of the Cursors SQL Trace Event Group?
7 events for the creation, access, and disposal of cursors.
What is the purpose of the Database SQL Trace Event Group?
6 events for data/log file grow/shrink as well as Database Mirroring state changes.
What is the purpose of the Database SQL Trace Event Group?
2 events to notify when a deprecated feature is used within the instance.
What is the purpose of the Errors and Warnings SQL Trace Event Group?
16 events for errors, warnings, and information messages being logged. Events to detect suspect pages, blocked processes, and missing column statistics.
What is the purpose of the Full Text SQL Trace Event Group?
3 events to track the progress of a full text index crawl.
What is the purpose of the Locks SQL Trace Event Group?
9 events for lock acquisition, escalation, release, and deadlocks.
What is the purpose of the OLEDB SQL Trace Event Group?
5 events for distributed queries and remote stored procedure calls.
What is the purpose of the Objects SQL Trace Event Group?
3 events that track when an object is created, altered, or dropped.
What is the purpose of the Performance SQL Trace Event Group?
14 events that allow you to capture show plans, use of plan guides, and parallelism. This event group also allows you to capture full text queries.
What is the purpose of the Progress Report SQL Trace Event Group?
1 event for online index creation progress.
What is the purpose of the Query Notifications SQL Trace Event Group?
4 events to track the parameters, subscriptions, and templates for query notifications.
What is the purpose of the Scans SQL Trace Event Group?
2 events to track when a table or index is scanned.
What is the purpose of the Security Audit SQL Trace Event Group?
44 events to track the use of permissions, impersonation, changes to security objects, management actions are taken on objects, start/stop of an instance, and backup/restore of a database.
What is the purpose of the Server SQL Trace Event Group?
3 events for mounting a tape, change to the server memory, and closing a trace file.
What is the purpose of the Sessions SQL Trace Event Group?
3 events for existing connections when the trace starts as well as tracking the execution of logon triggers and resource governor classifier functions.
What is the purpose of the Stored Procedures SQL Trace Event Group?
12 events for the execution of a stored procedure, cache usage, recompilation, and statements within a stored procedure.
What is the purpose of the Transactions SQL Trace Event Group?
13 events for the begin, save, commit, and rollback of transactions.
What is the purpose of the TSQL SQL Trace Event Group?
9 events for the execution of ad hoc T-SQL or XQuery calls. Events for an entire SQL batch as well as each statement within a batch.
What is the purpose of the User Configurable SQL Trace Event Group?
10 events that you can configure with SQL Trace.
What event groups are commonly captured to baseline and troubleshoot query performance?
Stored Procedures, Performance, and TSQL event groups.
What event group is used to define auditing quickly across a variety of security events?
The Security Audit event group.
What event group is commonly used to troubleshoot concurrency issues?
The Locks event group.
What events return a significant amount of data and should be used with caution on a very busy instance?
Performance / Showplan *

Stored Procedures / SP:StmtCompleted

Stored Procedures / SP:StmtStarting

TSQL / StmtCompleted

TSQL / StmtStarting
What is the purpose of the sp_trace_create trace module?
A stored procedure that creates a new trace object. Equivalent to the definition on the General tab of the New Trace dialog in Profiler.
What is the purpose of the sp_trace_generateevent trace module?
A stored procedure that allows you to define your own trace event.
What is the purpose of the sp_trace_setevent trace module?
A stored procedure that adds a data column for an event to be captured by a trace. You need to call sp_trace_setevent once for each data column being captured for an event. Equivalent to the event and data column selection grid in the Events Selection tab of the New Trace dialog in Profiler.
What is the purpose of the sp_trace_setfilter trace module?
A stored procedure that adds a filter to a trace. Equivalent to the Edit Filter dialog box in Profiler.
What is the purpose of the sp_trace_setstatus trace module?
A stored procedure that starts, stops, and closes a trace. A status of 0 stops a trace. A status of 1 starts a trace. A status of 2 closes a trace and removes the trace definition from the instance.
What is the purpose of the sp_trace_geteventinfo trace module?
A function that returns the events and data columns being captured by a trace.
What is the purpose of the sp_trace_getfilterinfo trace module?
A function that returns the filters applied to a specified trace.
What is the purpose of the sp_trace_getinfo trace module?
A function that returns status and property information about all traces defined in the instance.
What is the purpose of the sp_trace_gettable trace module?
A function that reads one or more trace files and returns the contents as a result set. Commonly used to import trace files into a table.
What is required to correlate a counter log trace with a trace file?
You need to have captured the StartTime data column in the trace.
Which events are commonly used to establish a performance baseline?
The RPC:Completed and SQL:BatchCompleted events.
What are the four places that error and information messages related to your server running SQL Server can be found?
Windows Event Log

SQL Server error log

SQL Server Agent log (sqlagent.out)

Database mail log
The current SQL Server error log is called errorlog (no extension) and located where?
MSSQL10.<instance>\MSSQL\LOG
What stored procedure can you run to extract the contents of the current error log?
sys.xp_readerrorlog
When the transaction log fills up and any write action attempted rolls back, what is the error logged to the SQL Server error log and Windows Application Event log?
9002
If a transaction log fills up, what 5 actions can you perform?
Back up the transaction log.

Add disk space to the volume that the transaction log file is on.

Move the log to a volume with more space.

Increase the size of the transaction log file.

Add another log file on a disk volume that has space.
A transaction log backup might not free up enough space within the log to be reused if any of the following occurs: ?
The database is participating in replication and the distribution database is not available.

You have an open transaction.

Database Mirroring is paused.

The mirror database is behind the principal.

A log scan is running.

SQL Server cannot increase the size of a file quickly enough.
If a db runs out of disk space, what errors are logged? What action can you take?
1101 and 1105. You could add a new file to the appropriate filegroup on a disk volume that has space.
Before adding files to a filegroup to resolve errors 1101 and 1105, what should you do?
Check to see if the data files have auto-grow disabled. If the disk still has space, you could increase the size of the data files and resolve the issue.
If tempdb runs out of space, what error codes are generated?
3958, 3959, 3966 and 3967
What does a service with a startup mode of Disabled appear as in the Start Mode column in the SQL Server Configuration Manager main window?
Other
The start mode for all SQL Server services in a clustered installation should be set to what?
Manual - they are controlled by the cluster service.
What permissions do SQL Server service accounts need?
Read and Write access to the folder(s) where the data/log files for system databases are stored.

Read and Write permissions on SQL Server registry keys.

Log On As A Service authority.

Sysadmin authority inside the SQL Server instance.
What sequence of events appear in the Windows Application Event viewer log indicate that SQL Server service account does not have sufficient permissions to access the data or log file(s) for either the master or tempdb databases?
Service startup

Device activation or file not found error

Service shutdown
Errors in what three databases can prevent an instance from starting?
Errors in the master, tempdb, and mssqlsystemresource databases can prevent an instance from starting. Errors in all other databases just make the problem database inaccessible until you can fix the problem.
When changing the startup parameters for the SQL Server service, what happens if a semicolon, which separates parameters, is followed by a space.
It interprets everything after the space as part of the previous parameter. Do not introduce spaces following semicolons.
What is the first indication you normally have for memory or processor issues?
A stack dump is generated.
What are 3 of SQL Server's 7 locking modes?
Shared

Exclusive

Update
What are the three lock types?
Row

Page

Table
What type of lock is acquired for reads?
A shared lock; you can have multiple shared locks on the same resource.
What type of lock is acquired for a resource being modified?
An exclusive lock; it is held until the modification is complete.
What is an update lock?
A hybrid of the shared and exclusive locks. An update lock starts out by acquiring a shared locks on resources until it finds the piece of data that needs to be modified, the shared lock is then changed to an exclusive lock while the data is changed.
What determines what type of lock to acquire?
The Lock Manager; uses an aggressive resource threshold, commonly called 2% rule, designed to minimize the number of locks needed--as each lock consumes memory. If determined that more than 2% of the rows on a page will need to be accessed, a page lock will be acquired. Likewise, if more than 2% of the pages in a table will be needed, a table lock is acquired.
What is lock escalation?
Because distribution statistics are not always accurate or don't exist, Lock manager uses lock escalation to allow a lock to be promoted to another lock type. A row lock can be escalated to a table lock and a page lock can be escalated to a table lock. Row locks are NEVER escalated to page locks.
What are the five transaction isolation levels?
READ UNCOMMITTED

READ COMMITTED

REPEATABLE READ

READ SERIALIZED

SNAPSHOT
What is the READ UNCOMMITTED transaction isolation level?
Data can be read that has not been committed. Although an exclusive lock still blocks another exclusive lock, any read operations ignore an exclusive lock.
What is the READ COMMITTED transaction isolation level?
This is the default isolation level for SQL Server. An exclusive lock blocks both shared as well as exclusive locks. A shared lock blocks an exclusive lock. Shared locks are released as soon as the data has been read.
What is the REPEATABLE READ transaction isolation level?
Exclusive locks block both shared and exclusive locks. Shared locks block exclusive locks. Shared locks are held for the duration of the transaction.
What is the READ SERIALIZED transaction isolation level?
All the restrictions as the REPEATABLE READ isolation level. In addition, you cannot insert a new row within the keyset range currently locked by the transaction. Locks are held for the duration of the transaction.
What is the SNAPSHOT transaction isolation level?
Uses the row versioning feature to keep shared and exclusive locks from blocking each other while maintaining data consistency. A read operation retrieves data from the version of the row prior to the start of a data modification operation.
How can you determine whether a process is blocked?
Use the sys.dm_exec_requests view. A process that is blocked will show a nonzero number in the blocking_session_id column. sp_who2 system stored procedure displays the SPID that is blocking a given process.
If you determine that a process is causing contention within your database, what command do you execute?
KILL <spid> where SPID is the system process ID of the blocking session.
What happens when a process is killed?
Any open transaction is rolled back.

A message is returned to the client.

An entry is placed in the SQL Server error log.

An entry is placed in the Windows Application Event Log.
What sequence described a how a deadlock occurs?
1. SPID1 acquires an exclusive lock on Row A.

2. SPID2 acquires an exclusive lock on Row C.

3. SPID1 attempts to acquire a shared lock on Row C and is blocked by the exclusive lock.

4. SPID2 attempts to acquire a shared lock on Row A and is also blocked by the exclusive lock.

Because both processes have to wait on the other process to release an exclusive lock before they can complete, the Lock Manager has an impossible situation. Lock Manager will kill one of the processes automatically (the one that has the least amount of accumulated time).
What error is returned when a deadlock is detected?
1205
How can you troubleshoot a deadlock?
Use SQL Server Profiler to capture a deadlock trace, which allows you to inspect the cause of the gridlock graphically.
What recommendations can DTA make?
Adding indexes

Dropping indexes

Partitioning tables

Storage aligning tables
What are the only events that DTA is concerned with?
RPC:Starting

RPC:Completed

SQL:Batch Starting

SQL:Batch Completed
What are the four steps that comprise DTA analysis?
1. Generate a workload for analysis.

2. Start DTA and connect to a server running SQL Server that contains a database to analyze the workload against.

3. Select the workload to use.

4. Specify tuning options.
Why would you want to consider running DTA against a test system rather than a production system?
The creation and destruction of statistics by DTA can place a very heavy load on the database being analyzed.
What are the valid input sources for DTA to analyze?
DTA can analyze queries and stored procedures that are stored in either a file or a table. The most common tuning source for DTA is a trace output file.
What three components does Resource Governor work with?
Resource Pools

Workload groups

Classification functions
What resources can be managed by Resource Governor?
CPU and memory
What is a workload group?
A label that you associate to a connection when it is created so that Resource Governor can assign the connection to the appropriate resource pool.
What is a classifier function?
A function that you create in the master database; only one classifier function can be active for Resource Governor at a time. It returns the name of the workload group that the session should be classified into. Executes after authentication but before connection handle returned to user's applications; performance issues in classification function could cause connection timeout.
When is the default resource pool used?
If a classifier function is not associated to Resource Governor, or the classifier function does not exist, returns NULL, or returns a nonexistent workload group, the user session is associated to the default resource pool.
What steps do you take to implement Resource Governor?
1. Enable Resource Governor.

2. Create one or more resource pools.

3. Create one or more workload groups.

4. Associate each workload group to a resource pool.

5. Create and test a classifier function.

6. Associate the classifier function to Resource Governor.
What views can you use to return information about the Resource Governor configuration?
SELECT * FROM sys.resource_governor_resource_pools

SELECT * FROM sys.resource_governor_workload_groups

SELECT * FROM sys.resource_governor_configuration

GO

When Resource Governor is active, the group_id column of sys.dm_exec_sessions is the ID of the workload group to which the session is assigned.
Where are all DMVs stored?
The sys schema.
What is the general purpose of DMVs with a prefix of: dm_db_* ?
General database space and index utilization.
What is the general purpose of DMVs with a prefix of: dm_exec_* ?
Statistics for queries that are executing as well as queries that have completed and still have plans in the query cache.
What is the general purpose of DMVs with a prefix of: dm_io_* ?
Disk subsystem statistics
What is the general purpose of DMVs with a prefix of: dm_os_* ?
Statistics related to the use of hardware resources.
What does the sys.dm_db_index_usage_stats view contain?
The number of times (and the last time) each index was used to satisfy a seek, scan or lookup as well as the number of times and the last time an update was performed on each index.
What 4 optional parameters does sys.dm_db_index_operational_stats take?
database_id

object_id

index_id

partition_id
What is db_index_operational_stats used for?
The function returns locking, latching and access statistics for each index--helps in determining contention issues.
What are the five optional parameters that sys.dm_db_index_physical_stats takes?
database_id

object_id

index_id

partition_id

mode
What is sys.dm_db_index_physical_stats takes used for?
It returns the size and fragmentation statistics for each index and should be the primary source for determining when an index needs to be defragmented.
What is the sys.dm_db_missing_index_* views used for?
Every time an index miss (when the Optimizer determines that an index would be beneficial but doesn't exist) occurs, SQL Server logs the details.
What is sys.dm_exec_connections used for?
Contains one row for each connection to the instance. Contains time connection was made along with properties of the connection and encryption settings. Can also tell you the total number of reads and writes for the connection as well as the last time a read or write was executed.
What is sys.dm_exec_sessions used for?
Contains a row for each currently authenticated session. In addition to login info, also track the current state of each possible query option and the current execution status. Also returns the accumulated reads, writes, CPU and query execution duration for the session.
What is sys.dm_exec_requests used for?
Contains one row for each currently executing request in the instance. you can use the blocking_session_id column to diagnose contention issues. Also contains the start time, elapsed time, estimated completion time, reads writes and CPU for the request. In addition, you can retrieve the database and command being executed, along with handles for the SQL statement and query plan associated with the request.
What is sys.dm_exec_query_stats used for?
Contains detailed stats on the performance and resources consumed for every query in the query cache. Lists the last time the query was executed and how many times the query was executed, along with the min and max execution time, logical/physical reads/writes/CPU, and a handle to the query plan generated by the Optimizer.
What is a handle?
It is the unique value by which SQL Server identifies the stored query plan and text stored in the query cache.
What is sys.dm_exec_sql_text used for?
It returns the text of the SQL statement associated to the handle that was passed in.
What is sys.dm_exec_query_plan used for?
It accepts a plan handle and returns the corresponding XML showplan.
What statement would you use to return the query and XML showplan for every query currently executing?
SELECT * FROM sys.dm_exec_requests CROSS APPLY sys.dm_exec_query_plan(plan_handle) CROSS APPLY sys.dm_exec_sql_text(sql_handle)
What does the sys.dm_io_virtual_file_stats function return?
Statistics about the reads and writes for every database file. Provides aggregate number as well as the bytes written to each file since the instance was started. You can also retrieve IOStalls. You use info from this function to determine whether disk contention is contributing to performance issues. You can also determine if you have disk I/O balanced across database files or if you have a disk hot spot.
What is an IOStall?
When SQL has to wait for the disk subsystem to become available to satisfy either a read or write operation; the time for IOStalls, measured in ms, is logged for each database file.
What does the sys.dm_io_pending_requests return?
Contains a row for each request that is waiting for the disk subsystem to complete an I/O request. If you have a request that appear frequently or stays for a long time, you probably have a disk bottleneck.
Data collection for the Performance Data Warehouse is configured using which collector types?
T-SQL Query

SQL Trace

Performance Counter

Query Activity
Because the Data Collector dynamically generates the table based on the results of the query defines, what must you ensure?
The result set does not contain columns named snapshot_time, snapshot_id, or database_name, because these are reserved for the Data Collector.

All columns in the result set must have a name.

Columns with an image, text, ntext, or XML data type cannot be included.

Only a single result set is returned.
What features is the Performance Data Warehouse based on?
The Performance Data Warehouse is built upon the Data Collector infrastructure. Data collection is based on SSIS packages and SQL Server Agent jobs.
What are the two types of clusters?
Standard windows cluster and majority node set cluster.
Where is the quorum database stored in each type of cluster?
In Standard windows cluster, it is on the shared array. In a majority node set cluster, it is stored locally on each node in the cluster.
What permissions does the cluster administrator account need?
It needs to be a member of the local administrators group on the machine.
What drives can you use in clustering? What if you are building a cluster that contains more than two nodes, has Windows Datacenter or has the 64-bit version of windows?
SCSI/iSCSI and Fibre. If any of those conditions are present, you are limited to only Fibre drives.
Can you use dynamic disks in clusters?
No, only basic disks and mount points.
What are some examples of cluster resources?
Cluster resources can be hardware, software, or networking. Some examples are IP addresses, network names, disk mounts, and Windows services.
How many network connections does a node need for clustering? Why?
Each node needs at least two network connections: One connection is used for public communications to applications on the network, and the other is used for private internal communications within the cluster.
How does the health check within a Windows cluster work?
The basic health check that is performed is called a LooksAlive test. This test consists of each node pinging the others.
What is the main difference between a standard cluster and a majority node set cluster?
A standard cluster uses a shared quorum database. A majority node set cluster maintains a separate quorum database on each node that is synchronized across all nodes. The majority of nodes (more than 50 percent) must be online for a majority node set cluster to function.
Which types of Windows accounts and groups can you use with a SQL Server cluster instance?
Domain users and domain groups must be used with SQL Server failover cluster instances. The SID for accounts and groups used must be resolvable across all nodes in the cluster. The SID for a local account or group cannot be resolved across machines.
With how many clustered instances can a single drive letter be used?
Although a clustered instance can address multiple drive letters, you can configure a given drive letter for only a single instance. This configuration prevents the possibility of having SQL Server running on one node while a different node has ownership of the disk resources required by the clustered instance.
What are the two health checks performed in a cluster, and which operations are executed?
The LooksAlive check executes every 5 seconds by default and issues a ping from all nodes to the IP address of the SQL Server clustered instance. The IsAlive check executes every 60 seconds by default, connects to the SQL Server clustered instance, issues SELECT @@SERVERNAME, and must receive a valid result set.
What are the three database mirroring roles? Which are required and which are optional?
principal - req

mirror - req

witness - optional
What port is the database mirroring endpoint defined for?
5022
What are the three operating modes that you can configure for database mirroring?
high availability

high performance

high safety
What servers does high availability mode in database mirroring require?
A principal server, a mirror server and a witness server.
In High Availability mode, how is failure detected?
High Availability mode uses a ping between each instance participating in the Database mirroring session.
How are transactions handled in databases operating in high availability mirroring mode?
SQL Server first writes all transactions into memory buffers within the SQL Server memory space. The system writes out these memory buffers to the transaction log. When SQL Server writes a transaction to the transaction log, the system triggers Database Mirroring to begin transferring the transaction log rows for a given transaction to the mirror. When the application issues a commit for the transaction, the transaction is first committed on the mirror database. An acknowledgment of the commit is sent back to the principal, which then enables the commit to be issued on the principal. At that point, the acknowledgment is sent back to the application, enabling it to continue processing. This process guarantees that all transactions are committed and hardened to the transaction log on both the principal and mirror databases before the commit is returned to the application.
What is a "split-brain" problem?
If the mirror were allowed to determine that it should serve the database by itself, it could introduce a situation whereby the database would be accessible to transactions on more than one server.
What are the general steps for automatic failure detection and failover in the High Availability operating mode?
1. The principal and mirror continuously ping each other.

2. The witness periodically pings both the principal and the mirror.

3. The principal fails.

4. The mirror detects the failure and makes a request to the witness to promote itself to the principal database.

5. The witness cannot ping the principal but can ping the mirror, so the witness agrees with the role reversal, and SQL Server promotes the mirror to the principal.

6. The principal server comes back online from the failure and detects that the mirror has been promoted to the principal.

7. SQL Server demotes the original principal to a mirror, and transactions begin flowing to this database to resynchronize it with the new principal.
What is the High Performance operating mode?
High Performance operating mode uses a principal and a mirror database, but it does not need a witness server. This operating mode provides a warm standby configuration that does not support automatic failure detection or automatic failover. High Performance operating mode does not automatically fail over because transactions are sent to the mirror asynchronously. Transactions are committed to the principal database and acknowledged to the application. A separate process constantly sends those transactions to the mirror, which introduces latency into the process. This latency prevents a Database Mirroring session from automatically failing over because the process cannot guarantee that the mirror has received all transactions when a failure occurs. Because the transfer is asynchronous, High Performance operating mode does not affect application performance, and you can have greater geographic separation between the principal and mirror. However, due to the data transfer being asynchronous, you can lose transactions in the event of a failure of the principal or when you force a failover of the mirroring session.
What is high safety operating mode?
High Safety operating mode transfers transactions synchronously, but it does not have a witness server. The synchronous transfer guarantees that all transactions committed at the principal are first committed at the mirror, and it requires the same performance considerations as the High Availability operating mode. However, the lack of a witness prevents automatic failover to the mirror if the principal fails. If the principal fails in High Safety operating mode, you must promote the mirror manually to serve the database.
One benefit of database mirroring is that it does not have caching issues, why is this?
In addition to sending transactions to the mirror, database mirroring performs periodic metadata transfers. The purpose of these metadata transfers is to cause the mirror to read pages into the data cache. This process maintains the cache on the mirror in a "semi-hot" state.
What is transparent client redirection in terms of database mirroring?
The new version of Microsoft Data Access Components (MDAC) that ships with Microsoft Visual Studio 2008 contains a Database Mirroring related feature within the connection object called Transparent Client Redirect. When a client makes a connection to a principal, the connection object caches the principal as well as the mirror. This caching is transparent to the application, and developers do not need to write any code to implement this functionality.
Which database mirroring mode is not recommended for normal operations?
High Safety - its synchronous transfers have a high-performance impact without the benefit of automatic failover.
What is the global communications thread in database mirroring?
When you initiate a Database Mirroring session, Service Broker is enlisted to manage a global communications thread. The global communications thread is used to detect when a participant in the Database Mirroring session is not available so that failover can occur when configured in High Availability operating mode and status messages can be passed between the session members.
How many threads are created per database in database mirroring and what is their purpose?
One thread per database participating in Database Mirroring sessions is created on the instance. The purpose of the database threads is to exchange messages between the principal and the mirror, such as transactions and acknowledgments. On the mirror, one thread per database is opened to manage the process of writing log records and maintaining the query and data caches.
What is the purpose of the additional thread that a witness has in database mirroring?
It is used to manage all the messages between the witness and participating principal/mirror sessions. The primary messages that are sent on the witness thread are state changes of the principal/mirror and failover requests.
What are the four general steps to prepare for Database mirroring?
1. Ensure that databases are set to use the Full recovery model.

2. Back up the primary database.

3. Restore the database to the instance hosting the mirror database by using the NORECOVERY option.

4. Copy all necessary system objects to the instance hosting the mirror database.
Why must you copy system objects when you configure Database mirroring?
It enables applications to function after a failover. The most common objects to transfer are logins, linked server, SQL Server Integration Services (SSIS) packages, SQL Server Agent jobs, custom error messages.
What can you use to transfer objects to the instance hosting the mirror database?
You can use SSIS, which includes the Transfer Logins task for transferring logins from one instance of SQL Server to another while keeping any passwords encrypted. SSIS also provides tasks for transferring SQL Server Agent jobs, error messages, and other types of objects.
If you do not remember the endpoint addresses when configuring database mirroring, what are two ways you can retrieve them?
-- You can query sys.database_mirroring_endpoints on each instance to get the endpoint address

-- You can start the Configure Database Mirroring Security Wizard by first right-clicking on the principal database and selecting Tasks, Mirroring. Then, in the Database Properties dialog box, click Configure Security and walk through each step. Because you have created the endpoints already, the wizard automatically retrieves information about them. When the wizard finalizes, it automatically enters the endpoint addresses into the appropriate fields for configuring Database Mirroring.
If your security access is defined using SQL Server logins, what additional action might you need to perform after failover to a mirrored database?
When you create a SQL Server login, a dummy security identifier (SID) is generated. This SID is then used to link the user in a database to the login for a server. If you do not re-create the SQL Server logins in the same order that you created them on the principal, a mismatch between the login and the user in the database occurs that can grant elevated permissions to a login. In this case, you need to execute ALTER LOGIN to remap the logins. However, because the mirror is inaccessible, you can perform this step only after a failover has occurred.
How do you fail back from a forced failover?
If the partners were synchronized at the time of the failover, you can apply transaction log backups to roll the failed partner forward in time, and then Database Mirroring finishes the resynchronization process. If the partners were not synchronized at the time of the failover, you need to remove mirroring and reinitialize.
Which server objects are your primary concern in the event of a failover?
The instance containing the mirror database must also have all the logins present that are required for applications and users to connect to the database. If the applications use linked servers, they also need to exist to prevent application failures. Other server objects such as SSIS packages and jobs are not as critical during the failover and can generally be addressed shortly after a failover after all applications are online.
When does a forced failover occur?
When the principal fails while the mirroring session is in an unsynchronized state, causing transactions that were committed on the principal to become lost. This is only possible for the High Performance operating mode.
What command do you execute to cause a mirrored session to fail over in High Performance Mode?
ALTER DATABASE <database name> SET PARTNER FORCE_SERVICE_ALLOW_DATA_LOSS;
What command to you execute to remove a mirroring session?
ALTER DATABASE <database name> SET PARTNER OFF;
What are the two modes that a secondary database participating in log shipping can be in?
Standby Mode or No Recovery Mode. When the secondary database is in Standby Mode, users can connect to and issue SELECT statements against the database. When the secondary database is in No Recovery Mode, users cannot connect to the database. In either mode, you can restore transaction logs to the secondary database. You cannot restore transaction logs when users are connected to the database, so you should not use Standby Mode for high-availability architectures.
What are the three components of log shipping?
The primary database is accessible and accepts transactions. The secondary database has a continuous chain of transaction logs applied to keep it up to date with the primary. The monitor instance sends alerts when the log shipping session is out of sync.
What happens to log shipping if the recovery model is changed to Simple?
Since log shipping depends on transaction log backup, this change would cause log shipping to cease functioning.
What affect would issuing a BACKUP LOG....WITH TRUNCATE_ONLY have on log shipping?
Since log shipping depends on transaction log backup, this change would cause log shipping to cease functioning.
What is the basic process for initializing log shipping?
1. Create a share on both the primary and secondary because the backups need to be accessed across servers.

2. Create jobs to back up transaction logs, copy logs to the secondary, and restore the logs.

3. Restore a full backup to the secondary database.

4. Restore all subsequent transaction logs.

5. Start up jobs to automate restoration of the logs.

6. Copy any instance-level objects upon which the secondary database depends to service applications.
The acronym ETL stands for?
Extract, Transform, Load
The acronym BI stands for?
Business Intelligence
What information does the Master database contain?
The meta data for the SQL server.
What information does the MSDB database contain?
Information about SQL jobs and other automated functions.
What is the Model database used for?
It is the basic template for all user created databases.
List the database objects that fall under the category of a "securable".
Databases, Tables, Indexes, Triggers, Views, Etc.
What is the difference between the "grant" and "with grant" permissions?
"Grant" allows access to an object or function and "with grant" allows the user access to an object or function and the ability to grant others access to the object or function.
What is the "Direct Admin Connection" and how do you access it?
It is the last line of connectivity to a server having issues and is access able via the SQLCMD prompt.
What is the tempdb database used for?
The tempdb database stores temporary tables and information.
When does the tempdb database dump its contents?
Upon server restart and when instructed to do so by the server or administrator.
What is the major difference between schemas in SQL 2000 and SQL 2005?
Schemas in SQL 2000 where associated exclusively with a particular database user account where schemas in SQL 2005 are not.
List the different database logging recovery models.
Simple, Bulk-Logged & Full
How does the "Full" recovery model allow for?
Logs all transactions occurring within a particular database.
How does the "Bulk-Logged" recovery model allow for?
Logs all transactions occurring within a particular database except those occurring as part of a BULK INSERT.
What types of operations are not logged via the "Bulk-Logged" recovery model?
BCP, BULK INSERT, WRITETEXT, UPDATETEXT, SELECT INTO, CREATE; ALTER; DBCC DBREINDEX index commands.
What happens to transactions in the transaction log when the "Simple" recovery model is in place?
Transactions are deleted from the transaction log upon being committed into the database.
How many bytes are in a Page?
Eight Thousand One Hundred Ninety-Two (8,192)
How many pages are in an Extent?
Eight (8)
How many bytes are in an Extent?
Sixty-Four Thousand (64K) aka 65,536 Bytes
What is the acronym for the management studio?
SSMS
How much space is required for the BIT datatype?
One (1) bit is required per value reserved in one (1) Byte increments for every 8 values.
What is the name of the naming convention that capitalizes the first character of each individual word?
Camel Case
What are the names of the different data types in SQL server?
1) Exact Numerics

2) Approximate Numerics

3) Date and Time

4) Character Strings

5) Unicode Character Strings

6) Binary Strings

7) Other (not the official name)
What is the name of the sample database included with SQL 2005?
AdventureWorks
What is the name of the sample database included with SQL 2000?
NorthWind
What data types are contained within the Exact Numerics group?
BIGINT, INT, SMALLINT, TINYINT, BIT, DECIMAL, NUMERIC, MONEY & SMALLMONEY
How many bytes are required for the BIGINT datatype?
8 Bytes
What is the numeric range for the BIGINT data type?
Negative to positive nine (9) followed by eighteen (18) zeros (roughly)
What is the numeric range for the INT data type?
Just over negative to positive two (2) billion
How many bytes are required for the INT data type?
Four (4) Bytes
How many bytes are required for the SMALLINT data type?
Two (2) Bytes
How many bytes are required for the TINYINT data type?
One (1) Byte
What is the numeric range for the SMALLINT data type?
-32,768 to 32,767
What is the numeric range for the TINYINT data type?
0 - 255
What is the maximum precision of the DECIMAL data type?
thirty-eight (38) digits to the left or right of the decimal point.
How many bytes are required for the DECIMAL data type?
Up to seventeen (17) bytes
Which datatypes not going to be supported in future releases of SQL Server?
Numeric
What are the new data types as of SQL 2005?
XML, VARCHAR(MAX), NVARCHAR(MAX)
What are the three levels of Principals?
Windows, SQL Server, Database
What are the Principal objects at the database level?
1) Database User

2) Database Role

3) Database Group

4) Application Role
What is a Principal?
Anything or anybody that can be given permission to access something.
What are the two types of Principals?
1) Individual aka Single Identities

2) Collection aka Fixed Server Roles
What are the Principal objects at the SQL Server level?
1) SQL Server Login

2) SQL Server Role
What are the Principal objects at the Windows level?
1) Local User Account

2) Domain User Account

3) Group
What are Securables?
Objects that are accessed
What are the different scopes of Securables?
1) Server

2) Database

3) Schema
What are the Server Securables?
1) Logins

2) HTTP Endpoints

3) Certificates

4) Events

5) Databases
What are the Database Securables?
1) Users

2) Roles

3) Application Roles

4) Assemblies

5) DDL Events

6) Schemas

7) Services

8) Message Types
What is the TLA CTE?
Common Table Expressions
What are the benefits for the "Snapshot Isolation Level" in SQL 2005?
1) Better isolates of transactions

2) No locks placed when reading data

3) No dirty reads

4) Uses tempdb to store row versions

5) Can significantly improve concurrency
What is the SQLCLR?
SQL Common Language Runtime
What does the SQLCLR allow for?
The SQLCLR allows you to run .NET code within Transact-SQL. Improves processor intensive tasks. Allows for regular expressions.
What is the TLA SMO?
SQL Management Objects
What is the TLA RMO?
Replication Management Objects
What does the acronym BIDS stand for?
Business Intelligence Development Studio
What is the Business Intelligence Development Studio used for?
It is a development environment for:

1) Analysis Services

2) Integration Services

3) Reporting Services
What component replaces DTS in SQL 2005?
SSIS (SQL Server Integration Services)
What does the acronym SSIS stand for?
SQL Server Integration Services
What features are included with SQL Server Integration Services?
1) Graphical tools and wizards

2) Tasks for performing workflow functions

3) Data sources and destinations for extracting and loading data

4) Transformations for cleaning, aggregating, merging, and copying data

5) Integration Services packages APIs

6) APIs for Integration Services object model
What is an aggregate query?
TBD
What are SQL Reporting Services?
Server-based reporting platform containing:

1) Tools for creating, managing and viewing reports

2) Report server to host and process reports

3) API to create application or custom tools
What type of data can be processed by Reporting Services?
Relational and Multidimensional data
What data sources are supported by Reporting Services?
1) SQL Server

2) Analysis Server

3) Oracle

4) >NET Framework data providers (OLEDB & ODBC giving access to MySQL, etc.)
What does the acronym OLAP stand for?
Online Analytical Processing
What does the acronym OLTP stand for?
Online Transaction Processing
What does the TLA UDM stand for?
Unified Dimensional Model
What are two types of multidimensional data schemas?
1) Star

2) Snowflake
What is a Fact Table?
TBD
SQL Server can run under different user accounts. What are they?
1) A "Domain User Account" (generally the best option when accessing other servers/network resources)

2) The "Local System Account" (never use)

3) The "Local Service Account" (okay to use, no access to network resources)

4) The "Network Service Account" (same as local service account with network access support)
Does SQL Server 2000 support multiple instances on a single server?
No (not totally proven yet)
What is the benefit of using multiple instances?
Allows you to continue using older versions of SQL as the default instance while installing new SQL 2005 named instances on the system.
How many instances of SQL 2005 can exist on a single server?
Enterprise Version = 50

All Other Versions = 16
What version/edition can you upgrade SQL Server 2000 Enterprise Edition to?
SQL Server 2005 Enterprise Edition ONLY
What is likely to break when upgrading SQL 2000 to SQL 2005?
TBD
What is the purpose of the Full-Text Search Service?
TBD
What is the purpose of the SQL Browser Service?
TBD
What is the name of the application that give you an overview and allow you to make GENERAL/SERVICE configuration changes on the SQL Server installation(s)?
SQL Server Configuration Manager
What is the default communications port number for SQL Server?
1433
What is the name of the application that give you an overview and allow you to make FEATURE configuration changes on the SQL Server installation(s)?
SQL Server 2005 Surface Area Configuration
What does the TLA AWE stand for?
Address Windowing Extensions
What does the AWE setting do?
Allows SQL Server to control its physical memory space directly on 32-bit Windows 2000/2003 server systems ONLY.
How much physical memory does the AWE setting allow SQL Server to access?
Sixty-Four (64) Gigabytes
What does the acronym TLA stand for?
Three Letter Acronym
True or False. The AWE setting will relinquish physical memory to other applications installed on the server as needed?
TRUE
As it relates to the SQL Server "Maximum Server Memory (in MB)" setting. What is the default value (2147483647) equate to?
2048 Terabytes
What do the "Configured Values" and "Running Values" radio buttons within various SQL Server configuration dialogs allow you to determine?
The allow you to see what settings are currently configured versus what settings are currently running. Helps to determine if a restart of SQL Server is required to implement various configuration changes.
How does the "Maximum Worker Threads" setting affect SQL Server?
It helps limit the resource utilization. Each connection to the server requires a new thread.
How does the "Boost SQL Server Priority" setting affect SQL Server?
Instructs the Windows Server operating system to give the SQL Server threads a higher priority
How does the "Use Windows fibers (lightweight pooling)" setting affect SQL Server?
TBD
How does the "Enable Server Proxy Account" setting affect SQL Server?
This setting overrides the default user account (typically the SQL Server service account) under which xp_cmdshell commands are executed.
How does the "Cross database ownership chaining" setting affect SQL Server?
Very dangerous setting. Used when database ownership must be maintained across multiple SQL Server instances.
How does the "Use query governor to prevent long-running queries" setting affect SQL Server?
Sets the maximum number of seconds that a query is allowed to run. If the query does not finish in the allotted time all transactions associated with the query are rolled-back and the query is shutdown.
What are the various options that can be set under the "Default Connection Options" setting?
1) Implicit Transactions

2) Cursor Close On Commit

3) ANSI Warnings

4) ANSI Padding

5) ANSI NULLS

6) Arithmetic Abort

7) Arithmetic Ignore

8) Quoted Identifier

9) No Count

10) ANSI NULL Default On

11) ANSI NULL Default Off

12) CONCAT NULL Yields NULL

13) Numeric Round Abort

14) XACT Abort
How does the "Require Distributed transactions for server-to-server communication" setting affect SQL Server?
TBD
How does the "Recovery Interval" setting affect SQL Server?
TBD
What does the acronym RDBMS stand for?
Relational Database Management System
Who created the relational database design principals?
Dr. E.F. Codd at IBM (aka Ted Codd)
What is "Set Theory"?
TBD
What is "Predicate Logic"?
TBD
How many levels are contained within the "Normal Forms"?
Three (3) basic normal forms followed by four (4) additional advanced forms.
What is the term "Relation" mean in set theory?
It refers to a table itself
What is the term "Attribute" mean in set theory?
It refers to the table columns
What is the term "Tulpe" (ta-ple) mean in set theory?
It refers to the rows in a table
What is the term "Candidate Key" mean in set theory?
Means of uniquely identifying a tuple in a relation based on one or more of its attributes.
What is the term "Primary Key" mean in set theory?
It is the attribute or combination of attributes by which each row is determined as unique.
What is the "Surrogate Key" mean in set theory?
It is "new" unique value (i.e. autonumber, GUID, etc) when none of the candidate keys are suitable to use as a primary key.
What is the "First Normal Form"?
"The Key,..."

First normal form requires that each attribute in a relation contain only one piece of information that you care about, and each piece of information that you care about should be held in only one attribute.
What is the "Second Normal Form"?
"...the whole key,..."

The database should be in first normal form, and every attribute should be functionally dependent on the entire primary key.

(Each relation should model just one entity or event)
What is the "Third Normal Form"?
"...and nothing but the key, so help me Codd."

The database should be in second normal form, and no attribute should be functionally dependent on an attribute that isn't in the primary key.

(Example: Don't store calculated values. Store the raw data, and use queries to perform calculations as needed unless the calculated values are automatically maintained, which is really a view.)
What is the minimum number of table to represent a many-to-many entity relationship?
Three (3)

(with the middle, resolver, or junction table storing the "pairings")
What are the two types of classes as it relates to relational data?
1) Base

2) Derived
What is a cascading update?
When a change is made to a primary key it will change all the cascade over to any related foreign keys.
What are the two new options created for foreign key cascading updates/deletes in SQL 2005?
1) Set NULL

2) Set Default
Relational Database Engines are to assist in the enforcement of data integrity. What are the three types of "Integrity"?
1) Entity Integrity

2) Domain Integrity

3) Referential Integrity



(which are all forms of domain integrity)
What does the DML query/update command SELECT do?
Extracts data from a database table.
What does the DML query/update command UPDATE do?
Updates data in a database table.
What does the DML query/update command DELETE do?
Deletes data from a database table.
What does the DML query/update command INSERT INTO do?
Inserts new data into a database table.
What does DML stand for?
Data Manipulation Language
What does the DDL query/update command CREATE TABLE do?
Creates a new database table.
What does the DDL query/update command ALTER TABLE do?
Alters (changes) a database table.
What does the DDL query/update command DROP TABLE do?
Deletes a database table.
What does the DDL query/update command CREATE INDEX do?
Creates and index (search key).
What does the DDL query/update command DROP INDEX do?
Deletes an index.
What does DDL stand for?
Data Definition Language
What does SQL stand for?
Structured Query Language
What is the syntax for using a select statement?
SELECT column_name(s)

FROM table_name
How do you select multiple columns using the SELECT statement?
Separate the column names with commas. Ex:



SELECT column_name1, column_name2

FROM table_name
What is the syntax used to select all columns from a table?
SELECT * FROM table_name
A semicolon is the standard way to separate each SQL statement in database systems that allow more than one SQL statement to be executed in the same call to the server. Is it necessary to use a semicolon?
Not always. It depends on the database program you are using.
The result from a SQL query is stored in a ______-___. Most database software systems use programming functions, like: Move-To-First-Record, Get-Record-Content, Move-To-Next-Record, etc. to navigate this with.
result-set
The DISTINCT keyword is used to return only distinct (different) values. What is the syntax of a SELECT statement with this keyword added to it?
SELECT DISTINCT column_name(s)

FROM table_name
What is the syntax for using a WHERE clause in a SELECT statement?
SELECT column_name FROM table

WHERE column_name <operator> value
True or False: SQL uses single quotes around text values (most database systems will also accept double quotes). Numeric values however should also be enclosed in quotes.
False, numeric values should not be enclosed in quotes.
The LIKE condition is used to specify a search for a pattern in a column. What is the syntax of using LIKE in a SELECT statement?
SELECT column_name FROM table

WHERE column_name LIKE pattern_type
A "%" sign can be used to define wildcards (missing letters in the pattern) both before and after the pattern in a LIKE condition. What would the syntax be for a statement that will return all people with first names that start with an 'O' in the table Persons? Assume the table has the following columns: FirstName, Last Name and Address
SELECT * FROM Persons

WHERE FirstName LIKE 'O%'
A "%" sign can be used to define wildcards (missing letters in the pattern) both before and after the pattern in a LIKE condition. What would the syntax be for a statement that will return all people with first names that contain the letters 'la' in them from the table Persons? Assume the table has the following columns: FirstName, Last Name and Address
SELECT * FROM Persons

WHERE FirstName LIKE '%la%'
The INSERT INTO statement is used to insert new rows into a table. What is the syntax for using this command?
INSERT INTO table_name

VALUES (value1, value2,....)
Using INSERT INTO, it is possible to specify which column to insert new data into. What is the syntax for this?
INSERT INTO table_name (column_name1, column_name2,...)

VALUES (value1, value2,....)
The UPDATE statement is used to modify the data in a table. What is the syntax for this?
UPDATE table_name

SET column_name = new_value

WHERE column_name = some_value
The DELETE statement is used to delete rows in a table. What is the syntax for this?
DELETE FROM table_name

WHERE column_name = some_value
The ORDER BY clause is used to sort the rows. What is the syntax for this?
SELECT column_name(s) FROM table_name

ORDER BY column_name(s)
What keyword would you use if you want to sort values in descending order?
DESC
What keyword would you use if you want to sort values in ascending order?
ASC
AND and OR join two or more conditions in a WHERE clause.



The AND operator displays a row if ___ conditions listed are true.
all
AND and OR join two or more conditions in a WHERE clause.



The OR operator displays a row if ___ of the conditions listed are true.
any
AND (and OR - see hint) join two or more conditions in a WHERE clause.



What is the syntax of these statements?
SELECT column_name FROM table_name
WHERE columname<operator>'value'
AND columname<operator>'value'
The IN operator may be used if you know the exact value you want to return for at least one of the columns. What is the syntax for this expression?
SELECT column_name FROM table_name
WHERE column_name IN (value1,value2,..)
The BETWEEN ... AND operator selects a range of data between two values. These values can be numbers, text, or dates. What is the syntax for this expression?
SELECT column_name FROM table_name
WHERE column_name
BETWEEN value1 AND value2
To display the persons outside the range used in a BETWEEN ... AND statement, use the ___ operator.
NOT
With SQL, aliases can be used for column names and table names. What is the syntax for Column Name Alias?
SELECT column_name AS column_alias FROM table_name
With SQL, aliases can be used for column names and table names. What is the syntax for Table Name Alias?
SELECT column_name FROM table_name AS table_alias
Tables in a database can be related to each other with keys. A primary key is a column with a ______ _____ for each row.
unique value
We can select data from two tables by referring to two tables. If we had one table named Employees which had columns named Employee_ID(primary key) and Name and another table called Orders that had columns named Prod_ID(primary key), Product, and Employee_ID how would we find out who has ordered what product?
SELECT Employees.Name, Orders.Product
FROM Employees, Orders
WHERE Employees.Employee_ID=Orders.Employee_ID
We can select data from two tables by referring to two tables. If we had one table named Employees which had columns named Employee_ID(primary key) and Name and another table called Orders that had columns named Prod_ID(primary key), Product, and Employee_ID how would we find out who ordered a printer?
SELECT Employees.Name
FROM Employees, Orders
WHERE Employees.Employee_ID=Orders.Employee_ID
AND Orders.Product='Printer'
We can select data from two tables with the INNER JOIN keyword. The INNER JOIN returns all rows from both tables where there is a match. If there are rows in table_name1 that do not have matches in table_name2, those rows will not be listed. What is the syntax for this?
SELECT table_name1.column_name, table_name2.column_name
FROM table_name1
INNER JOIN table_name2
ON table_name1.primary_key1 = table_name2.primary_key2
We can select data from two tables with the LEFT JOIN keyword. The LEFT JOIN returns all the rows from table_name1, even if there are no matches in table_name2. If there are rows in table_name1 that do not have matches in table_name2, those rows also will be listed. What is the syntax for LEFT JOIN?
SELECT table_name1.column_name, table_name2.column_name
FROM table_name1
LEFT JOIN table_name2
ON table_name1.primary_key1 = table_name2.primary_key2
We can select data from two tables with the RIGHT JOIN keyword. The RIGHT JOIN returns all the rows from table_name2, even if there are no matches in table_name1. If there had been any rows in table_name2 that did not have matches in table_name1, those rows also would have been listed. What is the syntax for RIGHT JOIN?
SELECT table_name1.column_name, table_name2.column_name
FROM table_name1
RIGHT JOIN table_name2
ON table_name1.primary_key1 = table_name2.primary_key2
The UNION command is used to select related information from two tables, much like the JOIN command. However, when using the UNION command all selected columns need to be of the ____ data type.
same
The UNION command is used to select related information from two tables, much like the JOIN command. With UNION, only distinct values are selected. What is the syntax for UNION?
SQL Statement 1

UNION

SQL Statement 2
The _____ ___ command is equal to the UNION command, except that it selects all values.
UNION ALL
The UNION ALL command is equal to the UNION command, except that UNION ALL selects all values. What is the syntax for UNION ALL?
SQL Statement 1

UNION ALL

SQL Statement 2
What is the syntax used to create a new database?
CREATE DATABASE database_name
What is the syntax for creating a new table in a database?
CREATE TABLE table_name

(
column_name1 data_type,
column_name2 data_type,
.......
)
In the example below, what does the numbers in parentheses indicate?



CREATE TABLE Person

(

Last Name varchar(30),

FirstName varchar,

Address varchar,

Age int(3)

)
The maximum length for the column.
The data type for creating a table with specifies what type of data the column can hold. What are the four integer values?
integer(size)

int(size)

smallint(size)

tinyint(size)
The data type for creating a table with specifies what type of data the column can hold. What are the two most common data types for decimal numbers?
decimal(size,d)

numeric(size,d)
The data type for creating a table with specifies what type of data the column can hold. What is the type used for a fixed length string (can contain letters, numbers, and special characters).
char(size)
The data type for creating a table with specifies what type of data the column can hold. What is the data type for a variable length string (can contain letters, numbers, and special characters).
varchar(size)
The data type for creating a table with specifies what type of data the column can hold. What is the data type used to hold a date?
date(yyyymmdd)
You can create an _____ in an existing table to locate rows more quickly and efficiently. It is possible to create one on one or more columns of a table, and each is given a name. The users cannot see them, they are just used to speed up queries.
index
A unique index means that two rows cannot have the same index value. What is the syntax for a unique index?
CREATE UNIQUE INDEX index_name
ON table_name (column_name)
A simple index, one without the UNIQUE keyword, allows duplicate values. What is the syntax for a simple index?
CREATE INDEX index_name

ON table_name (column_name)
You can delete an existing index in a table with the ____ _____ statement.
DROP INDEX
You can delete an existing index in a table with the DROP INDEX statement.



What is the syntax for Microsoft SQLJet (and Microsoft Access)?
DROP INDEX index_name ON table_name
You can delete an existing index in a table with the DROP INDEX statement.



What is the syntax for MS SQL Server?
DROP INDEX table_name.index_name
You can delete an existing index in a table with the DROP INDEX statement.



What is the syntax for IBM DB2 and Oracle?
DROP INDEX index_name
You can delete an existing index in a table with the DROP INDEX statement.



What is the syntax for MySQL?
ALTER TABLE table_name DROP INDEX index_name
To delete a table (the table structure, attributes, and indexes will also be deleted) you would use what syntax?
DROP TABLE table_name
To delete a database what syntax would you use?
DROP DATABASE database_name
If you only want to get rid of the data inside a table, and not the table itself, use the TRUNCATE TABLE command. What is the syntax for this command?
TRUNCATE TABLE table_name
The _____ _____ statement is used to add or drop columns in an existing table.
ALTER TABLE
The ALTER TABLE statement is used to add or drop columns in an existing table. What is the ADD command syntax?
ALTER TABLE table_name
ADD column_name datatype
The ALTER TABLE statement is used to add or drop columns in an existing table. What is the DROP COLUMN command syntax?
ALTER TABLE table_name
DROP COLUMN column_name
What is the syntax for built-in SQL functions?
SELECT function(column) FROM table
What are two basic types of functions in SQL?
Aggregate Functions and Scalar functions
GROUP BY... was added to SQL because aggregate functions (like SUM) return the aggregate of all column values every time they are called, and without the GROUP BY function it was impossible to find the sum for each individual group of column values. What is the syntax for this command?
SELECT column_name1,SUM(column_name2) FROM table GROUP BY column_name1
HAVING... was added to SQL because the WHERE keyword could not be used against aggregate functions (like SUM), and without HAVING... it would be impossible to test for result conditions.

The syntax for the HAVING function is?
SELECT column,SUM(column) FROM table
GROUP BY column
HAVING SUM(column) condition value
The SELECT INTO statement is most often used to create backup copies of tables or for archiving records. What is the syntax for this statement
SELECT column_name(s) INTO newtable [IN externaldatabase]
FROM source
What is a view in SQL?
A VIEW is a virtual table based on the result-set of a SELECT statement.
A view contains rows and columns, just like a real table. The fields in a view are fields from one or more real tables in the database. You can add SQL functions, WHERE, and JOIN statements to a view and present the data as if the data were coming from a single table. What is the syntax for a VIEW statement?



Note: The database design and structure will NOT be affected by the functions, where, or join statements in a view.
CREATE VIEW view_name AS
SELECT column_name(s)
FROM table_name
WHERE condition
Aggregate functions: What does AVG(column_name) do?
Returns the average value of a column.
Aggregate functions: What does COUNT(column_name) do?
Returns the number of rows (without a NULL value) of a column.
Aggregate functions: What does COUNT(*) do?
Returns the number of selected rows.
Aggregate functions: What does FIRST(column_name) do?
Returns the value of the first record in a specified field.
Aggregate functions: What does LAST(column_name) do?
Returns the value of the last record in a specified field.
Aggregate functions: What does MAX(column_name) do?
Returns the highest value of a column.
Aggregate functions: What does MIN(column_name) do?
Returns the lowest value of a column.
Aggregate functions: What does SUM(column_name) do?
Returns the total sum of a column.
Aggregate functions: What does FIRST(column_name) do?

(not supported in SQLServer2K)
Returns the value of the first record in a specified field.
Aggregate functions: What does LAST(column_name) do?

(not supported in SQLServer2K)
Returns the value of the last record in a specified field.
Scalar functions: What does UCASE(c) do?
Converts a field to upper case.
Scalar functions: What does LCASE(c) do?
Converts a field to lower case.
Scalar functions: What does MID(c,start[,end]) do?
Extract characters from a text field.
Scalar functions: What does LEN(c) do?
Returns the length of a text field.
Scalar functions: What does INSTR(c,char) do?
Returns the numeric position of a named character within a text field.
Scalar functions: What does LEFT(c,number_of_char) do?
Return the left part of a text field requested.
Scalar functions: What does RIGHT(c,number_of_char) do?
Return the right part of a text field requested.
Scalar functions: What does ROUND(c,decimals) do?
Rounds a numeric field to the number of decimals specified.
Scalar functions: What does MOD(x,y) do?
Returns the remainder of a division operation.
Scalar functions: What does NOW() do?
Returns the current system date.
Scalar functions: What does FORMAT(c,format) do?
Changes the way a field is displayed.
Scalar functions: What does DATEDIFF(d,date1,date2) do?
Used to perform date calculations.
RDBMS
Relational Database Management System
DML

DDL
Data Manipulation Language (DML)

Data Definition Language (DDL)
SQL SELECT Syntax
SELECT column_name(s)
FROM table_name
SELECT * FROM table_name
SQL SELECT Syntax
P_Id Last Name FirstName Address City

1 Hansen Ola Timoteivn 10 Sandnes
2 Svendson Tove Borgvn 23 Sandnes
3 Pettersen Kari Storgt 20 Stavanger

SELECT LastName,FirstName FROM Persons (exmp)
Last Name FirstName

Hansen Ola
Svendson Tove
Pettersen Kari
P_Id Last Name FirstName Address City

1 Hansen Ola Timoteivn 10 Sandnes
2 Svendson Tove Borgvn 23 Sandnes
3 Pettersen Kari Storgt 20 Stavanger

SELECT * FROM Persons
P_Id Last Name FirstName Address City

1 Hansen Ola Timoteivn 10 Sandnes
2 Svendson Tove Borgvn 23 Sandnes
3 Pettersen Kari Storgt 20 Stavanger
SQL WHERE Syntax
SELECT column_name(s)
FROM table_name
WHERE column_name operator value
P_Id Last Name FirstName Address City

1 Hansen Ola Timoteivn 10 Sandnes
2 Svendson Tove Borgvn 23 Sandnes
3 Pettersen Kari Storgt 20 Stavanger

SELECT * FROM Persons

WHERE City='Sandnes'
P_Id Last Name FirstName Address City

1 Hansen Ola Timoteivn 10 Sandnes
2 Svendson Tove Borgvn 23 Sandnes
Operators Allowed in the WHERE Clause
"= Equal
'<> Not equal
'> Greater than
'< Less than
'>= Greater than or equal
'<= Less than or equal
'BETWEEN Between an inclusive range
'LIKE Search for a pattern
'IN If you know the exact value you want to return for at least one of the columns"
OR Operator Example
SELECT * FROM Persons
WHERE FirstName='Tove'
OR FirstName='Ola
Combining AND & OR
SELECT * FROM Persons WHERE
Last Name='Svendson'
AND (FirstName='Tove' OR FirstName='Ola')
The ORDER BY Keyword
The ORDER BY keyword is used to sort the result-set by a specified column.
SQL ORDER BY Syntax
SELECT column_name(s)
FROM table_name
ORDER BY column_name(s) ASC / DESC
SQL ORDER BY Syntax with SELECT statement
SELECT * FROM Persons
ORDER BY Last Name
ORDER BY DESC Example
Now we want to select all the persons from the table above, however, we want to sort the persons descending by their last name.

SELECT * FROM Persons
ORDER BY Last Name DESC
SQL INSERT INTO Syntax v1
INSERT INTO table_name
VALUES (value1, value2, value3,...)