• 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/372

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;

372 Cards in this Set

  • Front
  • Back
What are the minimum hardware requirements for SQL Server 2008 32 bit?
Processor: P3 or higher
Processor Speed: 1 GHz or more
Memory: 512 MB
What are the minimum hardware requirements for SQL Server 2008 64 bit?
Processor: Itanium, Opteron, Athelon or Xeon/Pentium with EM64t support
Processor Speed: 1.6 GHz or more
Memory: 512 MB
The operating systems supported for all editions of SQL Server are:
Windows Server 2008 Standard or higher
Windows Server 2003 SP2 or higher
The operating systems supported for SQL Developer, Evaluation and Express are:
Windows XP Professional SP2 or higher
WIndows Vista Home Basic or higher
SQL Server Express is supported on:
Windows XP Home Edition SP2 or higher
Windows XP Home Reduced Media Edition
Windows XP Tablet Edition SP2 or higher
Windows XP Media Center 2002 SP2 or higher
Windows XP Professional Reduced Media Edition
Windows XP Professional Embedded Edition Feature Pack 2007 SP2
Windows XP Professional Embedded Edition for Point of Service SP2
Windows Server 2003 Small Business Server Standard Edition R2 or higher
What version of Server 2008 is SQL 2008 not supported on and why?
SQL Server 2008 is not supported on Windows Server 2008 Server Core. Windows Server
2008 Server Core is not supported because the .NET Framework is not supported on Server
Core. SQL Server 2008 relies on .NET Framework capabilities to support FILESTREAM,
SPATIAL, and DATE data types, along with several additional features.
What editions is SQL Server 2008 available in?
Enterprise
Standard
Workgroup
Express
Compact
Developer
Evaluation
How do the developer and evaluation editions differ from the enterprise edition?
They contain the same functionality, but cannot be run in a production environment.
Which editions of SQL Server are designed as storage engines for embedded applications with limited hardware and feature support?
Express and Compact editions are designed as storage engines for embedded applications and support only a single CPU, up to 1 GB of RAM, and a maximum
database size of 4 GB.
How many CPUs are supported by the Standard, Workgroup, Express and Compact editions?
Standard: 4
Workgroup: 4
Express: 1
Comact: 1
What database size is supported by the Standard, Workgroup, Express and Compact editions?
Standard: Unlimited
Workgroup: Unlimited
Express: 4 GB
Compact: 4 GB
What RAM size is supported by the Standard, Workgroup, Express and Compact editions?
Standard: Unlimited
Workgroup: Unlimited
Express: 1 GB
Compact: 1 GB
Which versions among Standard, Workgroup, Express and Compact allow the use of SQL Server Management Studio?
Standard: Yes
Workgroup: Yes
Express: Separate Download
Compact: No
Which versions among Standard, Workgroup, Express and Compact allow for full text search?
Standard: Yes
Workgroup: Yes
Express: Advanced services only
Compact: No
Which versions among Standard, Workgroup, Express and Compact allow for partitioning?
Standard: No
Workgroup: No
Express: No
Compact: No
Which versions among Standard, Workgroup, Express and Compact allow for parallel operations?
Standard: No
Workgroup: No
Express: No
Compact: No
Which versions among Standard, Workgroup, Express and Compact allow for multiple instances?
Standard: No
Workgroup: No
Express: No
Compact: No
Which versions among Standard, Workgroup, Express and Compact allow for database snapshots?
Standard: No
Workgroup: No
Express: No
Compact: No
Which versions among Standard, Workgroup, Express and Compact allow for scalable shared databases?
Standard: No
Workgroup: No
Express: No
Compact: No
Which versions among Standard, Workgroup, Express and Compact allow for index views?
Standard: No
Workgroup: No
Express: No
Compact: No
Which versions among Standard, Workgroup, Express and Compact allow for log compression?
Standard: No
Workgroup: No
Express: No
Compact: No
Which versions among Standard, Workgroup, Express and Compact allow for clustering?
Standard: 2 nodes
Workgroup: No
Express: No
Compact: No
Which versions among Standard, Workgroup, Express and Compact allow for database mirroring?
Standard: single-thread
Workgroup: No
Express: No
Compact: No
Which versions among Standard, Workgroup, Express and Compact allow for online operations?
Standard: No
Workgroup: No
Express: No
Compact: No
Which versions among Standard, Workgroup, Express and Compact allow for resource governor?
Standard: No
Workgroup: No
Express: No
Compact: No
Which versions among Standard, Workgroup, Express and Compact allow for backup compression?
Standard: No
Workgroup: No
Express: No
Compact: No
Which versions among Standard, Workgroup, Express and Compact allow for hot add memory/CPU?
Standard: No
Workgroup: No
Express: No
Compact: No
Which versions among Standard, Workgroup, Express and Compact allow for Data Encryption?
Standard: Limited
Workgroup: Limited
Express: Limited
Compact: Password-based only
Which versions among Standard, Workgroup, Express and Compact allow for Change Data Capture?
Standard: No
Workgroup: No
Express: No
Compact: No
Which versions among Standard, Workgroup, Express and Compact allow for Data Compression?
Standard: No
Workgroup: No
Express: No
Compact: No
Which versions among Standard, Workgroup, Express and Compact allow for Policy-based management?
Standard: Yes
Workgroup: No
Express: No
Compact: No
Which versions among Standard, Workgroup, Express and Compact allow for Performance Data Collection?
Standard: Yes
Workgroup: No
Express: No
Compact: No
Which versions among Standard, Workgroup, Express and Compact allow for CLR?
Standard: Yes
Which versions among Standard, Workgroup, Express and Compact allow for XML?
Standard: Native
Workgroup: Native
Express: Native
Compact: Stored as text
Which versions among Standard, Workgroup, Express and Compact allow for Spatial Data?
Standard: Yes
Which versions among Standard, Workgroup, Express and Compact allow for Stored procedures, triggers and views?
Standard: Yes
Workgroup: Yes
Express: Yes
Compact: No
Which versions among Standard, Workgroup, Express and Compact allow for Merge Replication?
Standard: Yes
Workgroup: Yes
Express: Subscriber only
Compact: Subscriber only
Which versions among Standard, Workgroup, Express and Compact allow for Transactional Replication?
Standard: Yes
Workgroup: Subscriber only
Express: Subscriber only
Compact: No
Regarding SSIS ,which versions among Standard, Workgroup, Express and Compact have an Import/Export Wizard?
Standard: Yes
Workgroup: Yes
Express: NA
Compact: NA
Regarding SSIS ,which versions among Standard, Workgroup, Express and Compact have a Package Designer?
Standard: Yes
Workgroup: Yes
Express: NA
Compact: NA
Regarding SSIS ,which versions among Standard, Workgroup, Express and Compact support Data Mining?
Standard: No
Workgroup: No
Express: NA
Compact: NA
Regarding SSIS ,which versions among Standard, Workgroup, Express and Compact support Fuzzy grouping/lookup?
Standard: No
Workgroup: No
Express: NA
Compact: NA
Regarding SSIS ,which versions among Standard, Workgroup, Express and Compact support term extraction/lookup?
Standard: No
Workgroup: No
Express: NA
Compact: NA
Regarding SSIS ,which versions among Standard, Workgroup, Express and Compact support OLAP processing?
Standard: No
Workgroup: No
Express: NA
Compact: NA
Regarding SSRS ,which versions among Standard, Workgroup, Express and Compact support Microsoft Office Integration?
Standard: Yes
Workgroup: Yes
Express: Advanced Services Only
Compact: NA
Regarding SSRS ,which versions among Standard, Workgroup, Express and Compact support report builder?
Standard: Yes
Workgroup: Yes
Express: Advanced Services Only
Compact: NA
Regarding SSRS ,which versions among Standard, Workgroup, Express and Compact support Scale-out reporting?
Standard: No
Workgroup: No
Express: No
Compact: NA
Regarding SSRS ,which versions among Standard, Workgroup, Express and Compact support Data-driven subscriptions?
Standard: No
Workgroup: No
Express: No
Compact: NA
Regarding SSAS-OLAP support ,which versions among Standard, Workgroup, Express and Compact have support Linked measures/dimensions?
Standard: No
Workgroup: No
Express: NA
Compact: NA
Regarding SSAS-OLAP support ,which versions among Standard, Workgroup, Express and Compact have support Perspectives?
Standard: No
Workgroup: No
Express: NA
Compact: NA
Regarding SSAS-OLAP support, which versions among Standard, Workgroup, Express and Compact have support for Partitioned cubes?
Standard: No
Workgroup: No
Express: NA
Compact: NA
Regarding SSAS-Data Mining support, which versions among Standard, Workgroup, Express and Compact have support for Time series?
Standard: No
Workgroup: No
Express: NA
Compact: NA
Regarding SSAS-Data Mining support, which versions among Standard, Workgroup, Express and Compact have support for Parallel processing and prediction?
Standard: No
Workgroup: No
Express: NA
Compact: NA
Regarding SSAS-Data Mining support, which versions among Standard, Workgroup, Express and Compact have support for Advanced mining algorithms?
Standard: No
Workgroup: No
Express: NA
Compact: NA
In addition to the core database engine technologies, SQL Server 2008 Enterprise
supports Service Broker for asynchronous processing.
summary
Which core components of SQL, which run as services, require dedicated service accounts?
Database Engine and SQL Server Agent.
What is a collation sequence?
A collation sequence defines the character set that is supported, including case sensitivity, accent sensitivity, and kana sensitivity.
What are the two authentication modes that you can set for SQL Server authentication?
Windows Only (integrated security) or Windows and SQL Server (mixed mode).
Why can you not use the Windows Service Control Applet to change service accounts or service account passwords?
SQL Server Confi guration Manager needs to be used, because it includes the code to regenerate the service master key that is critical to the operation of SQL Server services.
What is an enumeration request and when would you disable responses?
By disabling enumeration responses by setting the Hide Instance to Yes, you prevent someone from using discovery techniques to locate servers running SQL Server for a possible attack.
What is database mail?
Database mail enables a computer running SQL to send outbound mail messages. It uses SMTP rather than MAPI.
What are the two types of profiles that you can configure within Database Mail?
Either a public or private profile. A public profile can be accessed by any user with the ability to send mail. A private profile can be accessed only by those users who have been granted access to the mail profile explicitly.
How is the SQL Server Agent releated to Database Mail?
Database Mail utilizes the services of SQL Server Agent to send messages as a background process. If SQL Server Agent is not running, messages will accumulate in a queue within the Msdb database.
What are the two file types that SQL uses?
Data and Transaction log files. Data files are responsible for the long-term storage of all the data within a database. Transaction log files are responsible for storing all the transactions that are executed against a database.
When you create a database, it should have three files and two filesgroups; what are they?
You should have a file with an .mdf extension within a filegroup named PRIMARY, a file with an .ndf extension in a filegroup with any name that you choose, and the transaction log with an .ldf extension.
After you create a database, why should you mark the second database as the default filegroup?
By changing the default filegroup, you ensure that any objects you create are not accidentally placed on the primary filegroup and that only the system objects for the database reside on the primary filegroup--reduces the possibility of introducing corruption.
What is the command to change the default filegroup?
ALTER DATABASE <database name> MODIFY FILEGROUP <filegroup name> DEFAULT
What determines the maximum transaction throughput for any database?
The amount of data per second that SQL Server can write to the transaction log.
What is the FILESTREAM feature?
FILESTREAM feature allows you to associate files with a database. The files are stored in a folder on the operating system, but are linked directly into a database where the files can be backed up, restored, full-text-indexed, and combined with other structured data.
What is the filestream.hdr file?
It is a system file that is created to manage the files subsequently written to the filestream folder.
What is unique about the FILENAME property defined for a FILESTREAM filegroup?
The initial part of the folder path definition must exist; however, the last folder in the path defined cannot exist and is created automatically
In addition to temporary objects, what does SQL Server use the tempdb for?
Worktables used in grouping/sorting operations, worktables to support cursors, the version store supporting snapshot isolation level, and overflow for table variables. You can also cause index build operations to use space in tempdb.
Every database in SQL server has a recovery model property; which recovery models are available?
Full
Bulk-logged
Simple
In the full recovery model, what changes are logged to the transaction logs and how long are the changes retained in the transaction logs?
All changes made, using both data manipulation language (DML) and data definition language (DDL), are logged to the transaction log. Changes are retained in the transaction log indefinitely and are removed only by executing a transaction log backup.
What are the operations that are performed in a minimally logged manner with the database set in the Bulk-logged recovery model?
BCP
BULK INSERT
SELECT. . .INTO
CREATE INDEX
ALTER INDEX. . .REBUILD
How does the simple recovery model differ from the full recovery model?
A database in the Simple recovery model logs operations to the transaction log exactly as the Full recovery model does. However, each time the database checkpoint process executes, the committed portion of the transaction log is discarded. A database in the Simple recovery model cannot be recovered to a point in time because it is not possible to issue a transaction log backup for a database in the simple recovery model.
What is the command to set the recovery model of a database?
ALTER DATABASE database_name SET RECOVERY {FULL | BULK_LOGGED | SIMPLE }
What types of backup (Full, Differential, Trans log) are available for a database in the Full recovery model?
Full: Yes
Differential: Yes
Transaction Log: Yes
What types of backup (Full, Differential, Trans log) are available for a database in the Bulk Logged model?
Full: Yes
Differential: Yes
Transaction Log: Yes/No minimally logged
What types of backup (Full, Differential, Trans log) are available for a database in the Simple recovery model?
Full: Yes
Differential: Yes
Transaction Log: No
What is the PAGE_VERIFY CHECKSUM?
Allows you to discover and log damaged page files (default configuration of SQL does not check for damaged pages).
What happens when a damaged page is encountered?
If PAGE_VERIFY CHECKSUM is not enabled, database could go offline. If enabled, an 824 error is returned to the calling application and logged to the SQL Server error log and Windows Application Event log and the ID of the damaged page is logged to the suspect_pages table in the msdb database.
What happens if AUTO_CLOSE is enabled?
When the last connection to a database is closed, SQL Server shuts down the database and releases all resources related to the database. When a new connection is made to the database, SQL Server starts up the database and begins allocating resources.
What happens if AUTO_SHRINK is enabled?
SQL Server periodically checks the space utilization of data and transaction log files. If the space checking algorithm finds a data file that has more that 25 percent free space, the file automatically shrinks to reclaim disk space.
What happens if AUTO_CREATE_STATISTIS is enabled?
SQL Server automatically creates statistics that are missing during the optimization phase of query processing.
What happens if AUTO_UPDATE_STATISTIS is enabled?
Updates out-of-date statistics during query optimization.
What happens if AUTO_UPDATE_STATISTIS_ASYNCH is enabled?
Controls whether statistics are updated during query optimization or if query optimization continues while the statistics are updated asynchronously.
What is the CHANGE_TRACKING database option that SQL Server 2008 introduced? How do you specify how long to keep tracking information?
Change tracking is a lightweight mechanism that associates a version with each row in a table that has been enabled for change tracking. Each time the row is changed, the version number is incremented. The CHANGE_RETENTION option and the AUTO_CLEANUP option control how long to keep tracking information.
What are the three states that a database can be set to in order to control access?
ONLINE
OFFLINE
EMERGENCY
What access is granted to a database in an EMERGENCY state?
Can only be accessed by members of the db_owner role and the only command allowed to be executed is SELECT.
How can you control the ability to modify data for an online database? What impact does this have on transaction log files?
By setting the database to READ_ONLY or READ_RIGHT. A database in READ_ONLY cannot be written to and SQL removes any transaction log file that is specified for the database. If changed to READ_WRITE, SQL recreates the transaction log file.
What three option settings control user access to a database?
SINGLE_USER
RESTRICTED_USER
MULTI_USER
A database set to RESTRICTED_USER only allows access to: ?
members of the db_owner, dbcreator and sysadmin roles.
What happens if multiple users are using the database when you change the mode to SINGLE_USER or users conflict with the allowed set for RESTRICTED_USER? What option can you add to to control this?
The ALTER DATABASE command is blocked until all the non-allowed users disconnect. ROLLBACK IMMEDIATE forcibly rolls back any open transactions along with disconnecting any nonallowed users. Using ROLLBACK AFTER <number of seconds> waits for the specified number of seconds before rolling back transactions and disconnecting users.
What is the benefit of a parameterized query?
It can reuse cached query plans more frequently and avoid the time required to build a query plan.
How can you force SQL Server to read every page from disk and check the integrity?
Use the DBCC CHECKDB command.
When DBCC CHECKDB is executed, what actions are performed?
Checks page allocation within the database
Checks the structural integrity of all tables and indexed views
Calculates a checksum for every data and index page to compare against the stored checksum
Validates the contents of every indexed view
Checks the database catalog
Validates Service Broker data within the database
What commands does DBCC CHECKDB execute?
DBCC CHECKALLOC, to check the page allocation of the database
DBCC CHECKCATALOG, to check the database catalog
DBCC CHECKTABLE, for each table and view in the database to check the structural integrity
If a database is participating in a database mirroring session and a corrupt page is found using PAGE_VERIFY CHECKSUM, what happens?
SQL Server automatically retrieves a copy of the page from the mirror, replaces the page on the principal, and logs an entry in the sys.dm_db_mirroring_auto_page_repair view.
If your application accesses multiple databases or you are creating an application with multiple databases that do not need to be stored on separate instances for increased capacity, what should you do?
You should combine the objects into a single database and use schemas to separate groups of objects.
What are the nine numeric data types in SQL Server 2008?
TINYINT
SMALLINT
INT
BIGINT
DECIMAL(P,S) and NUMERIC(P,S)
SMALLMONEY
MONEY
REAL
FLOAT(N)
What is the range of values and how much storage space is required for the data type TINYINT?
Values: 0 to 255
Space: 1 byte
What is the range of values and how much storage space is required for the data type SMALLINT?
Values: -32,768 to 32,767
Space: 2 bytes
What is the range of values and how much storage space is required for the data type INT?
Values: -2^31 to 2^31-1
Space: 4 bytes
What is the range of values and how much storage space is required for the data type BIGINT?
Values: -2^63 to 2^63-1
Space: 8 bytes
What is the range of values and how much storage space is required for the data type DECIMAL(P,S) and NUMERIC(P,S)?
Value: - 10^38 +1 through 10^38 - 1
Space: Precision Storage bytes
1 - 9 5
10-19 9
20-28 13
29-38 17
What is the range of values and how much storage space is required for the data type SMALLMONEY?
Value: - 214,748.3648 to 214,748.3647
Space: 4 bytes
What is the range of values and how much storage space is required for the data type MONEY?
Value: -922,337,203,685,477.5808 to 922,337,203,685,477.5807
Space: 8 bytes
What is the range of values and how much storage space is required for the data type REAL?
Value: - 3.40E + 38 to -1.18E - 38, 0 and 1.18E - 38 to 3.40E + 38
Space: 4 bytes
What is the range of values and how much storage space is required for the data type FLOAT(N)?
Value: - 1.79E+308 to -2.23E-308, 0 and 2.23E-308 to 1.79E+308
Space: depends on the value of n; if n's value is between 1-24, is has a precision of 7 digits and requires 4 bytes; if n is between 25-53, the precision is 15 digits and requires 8 bytes.
What are the two parameters of decimal data types?
Precision and scale. The precision indicates the total number of digits that can be stored both to the left and to the right of the decimal. The scale indicates the maximum number of digits to the right of the decimal point.
What are the four character data types in SQL Server 2008? How much storage space is associated with each one?
CHAR(n) - 1 byte per character defined by n, up to a maximum of 8,000 bytes.
VARCHAR(n) - 1 byte per character stored up to a maximum of 8,000 bytes.
NCHAR(n) - 2 bytes per character defi ned by n, up to a maximum of 4,000 bytes
NVARCHAR(n) - 2 bytes per character stored up to a maximum of 4,000 bytes
What are the 6 time and date data types in SQL Server 2008?
SMALLDATETIME
DATETIME
DATETIME2
DATETIMEOFFSET
DATE
TIME
What are the range of values, the accuracy and storage space associated with SMALLDATETIME?
Range: 01/01/1900 to 06/06/2079
Accuracy: 1 minute
Storage: 4 bytes
What are the range of values, the accuracy and storage space associated with DATETIME?
Range: 01/01/1753 to 12/31/9999
Accuracy: 0.00333 seconds
Storage: 8 bytes
What are the range of values, the accuracy and storage space associated with DATETIME2?
Range: 01/01/0001 to 12/31/9999
Accuracy: 100 nanoseconds
Storage: 6 to 8 bytes
What are the range of values, the accuracy and storage space associated with DATETIMEOFFSET?
Range: 01/01/0001 to 12/31/9999
Accuracy: 100 nanoseconds
Storage: 8 to 10 bytes
DATETIMEOFFSET allows you to store a time zone.
What are the range of values, the accuracy and storage space associated with DATE?
Range: 01/01/0001 to 12/31/9999
Accuracy: 1 day
Storage: 3 bytes
What are the range of values, the accuracy and storage space associated with TIME?
Range: 00:00:00.0000000 to 23:59:59.9999999
Accuracy: 100 nanoseconds
Storage: 3 to 5 bytes
What are the three binary data types in SQL Server 2008?
BIT
BINARY
VARBINARY
What are the range of values and storage space associated with BIT?
Range: Null, 0, 1
Storage: 1 bit
What are the range of values and storage space associated with BINARY?
Range: Fixed-length binary data
Storage: Up to 8,000 bytes
What are the range of values and storage space associated with VARBINARY?
Range: Variable-length binary data
Storage: Up to 8,000 bytes
What is the XML data type?
It allows you to store and manipulate Extensible Markup Language (XML) documents natively. You are limited to 2 GB per document as well as 128 levels within a document.
What is an XML Schema Collection used for?
When an XML Schema Collection is applied to an XML column, the only documents allowed to be stored within the XML column must first validate to the associated XML schema collection.
What are the two spatial data types that SQL Server 2008 supports?
GEOMETRY - based on Euclidian geometry and is used to store points, lines, curves, and polygons
GEOGRAPHY - based on an ellipsoid and is used to store data such as latitudes and longitudes.
What are the 7 different geometric objects that a GEOMETRY column can contain?
1. Point - Has x and y coordinates, with optional elevation and measure values.
2. LineString - A series of points that defi nes the start, end, and any bends in the line, with optional elevation and measure values.
3. Polygon - A surface defi ned as a sequence of points that defi nes an exterior boundary, along with zero or more interior rings. A polygon has at least three distinct points.
4. GeometryCollection - Contains one or more instances of other geometry shapes, such as a Point and a LineString.
5. MultiPolygon - Contains the coordinates for multiple Polygons.
6. MultiLineString - Contains the coordinates of multiple LineStrings.
7. MultiPoint - Contains the coordinates of multiple Points.
What is the HIERARCHYID data type?
The HIERARCHYID data type is used to organize hierarchical data, such as organization charts, bills of materials, and fl owcharts. The HIERARCHYID stores a position within a tree hierarchy.
What are the 7 properties that you can apply to a column?
1. nullability
2. COLLATE
3. IDENTITY
4. ROWGUIDCOL
5. FILESTREAM
6. NOT FOR REPLICATION
7. SPARSE
What database property sets the nullability property?
ANSI_NULL_DEFAULT
How can you insert a value into an identity column explicitly?
By using the SET IDENTITY_INSERT <table name> ON command.
How do you change the next value generated for an identity column by modifying the seed?
Use the DBCC CHECKIDENT command.
What is the ROWGUIDCOL property used for?
Used mainly by merge replication to designate a column that is used to identify rows uniquely across databases. The ROWGUIDCOL property is used to ensure that only a single column of this type exists and that the column has a UNIQUEIDENTIFIER data type.
What data type do columns that have the FILESTREAM property applied have?
VARBINARY(MAX). The column maintains a 16 byte identifier for the file.
Can you implement database mirroring against a database containing data stored with FILESTREAM?
NO
How is a FILEGROUP designated for FILESTREAM storage treated in a database snapshot?
It is off-line and inaccessible.
What is the SPARSE option used for?
When a NULL is stored in a column designated as SPARSE, no storage space is consumed. However, non-NULL values require 4 bytes of storage space in addition to the normal space consumed by the data type. The column must allow nulls.
What can you not apply the SPARSE property to?
- Columns with the ROWGUIDCOL or IDENTITY property
- TEXT, NTEXT, IMAGE, TIMESTAMP, GEOMETRY, GEOGRAPHY, or user-defined data types
- A VARBINARY(MAX) with the FILESTREAM property
- A computed column of a column with a rule or default bound to it
- Columns that are part of either a clustered index or a primary key
- A column within an ALTER TABLE statement
What is the maximum size a row can be before you cannot issue an ALTER statement to either change a column to SPARSE or add an additional SPARSE column? Why?
4,009 bytes. During the ALTER, each row is recomputed by writing a second copy of the row on the same data page. Because two copies of a row that exceed 4,009 bytes would exceed the 8,018 bytes allowed per page, the ALTER TABLE statement fails.
How can you make a column SPARSE if the row size is more than 4,009 bytes?
- Reduce the data within a row so that the maximum row size is greater than 4,009 bytes
- Create a new table, copy all the data to the new table, drop the old table, and then rename the newly created table
- Export the data, truncate the existing table, make the changes, and import the data back into the table
If you do not want to incur the overhead of making the calculation of a Computed Column at runtime, what can you specify?
The PERSISTED property. If a computed column is PERSISTED, SQL Server stores the result of the calculation in the row and updates the value anytime data that the calculation relies upon is changed.
What is row-level compression? What is the limitation?
Allows you to compress individual rows to fit more rows on a page, which reduces the storage space for the table because you don't need to store as many pages on a disk. Because you can uncompress the data at any time, in order for it to succeed, you cannot use compression to store more than 8,060 bytes in a single row.
What commands do you use to have SQL Server compress new data added to a heap?
BULK INSERT or INSERT INTO...WITH (TABLLOCK) statement
Do compression settings for a table pass to any nonclustered indexes or indexed views craeted against a table?
NO
Why can you not compress VARCHAR(MAX), NVARCHAR(MAX) and VARBINARY(MAX) data?
They store data in specialized structures outside the row; any data stored outside the row cannot be compressed.
How many columns can a standard table in SQL 2008 have?
1,024 columns
What are wide tables?
Tables that exceed 1,024 columns (up to a max of 30,000columns) by using a column set definition; data stored in any row still cannot exceed 8,019 bytes unless you have a VARCHAR(MAX), NVARCHAR(MAX) or VARBINARY(MAX) column defined for the table.
Where are temporary tables stored?
The tempdb database.
What are the two types of temporary tables and how are they designated?
Local or global. Local is designated by a name beginning with # and is visible only within the connection that created it. A global is designated by a name beginning with ## and is visible across all connections to the instance.
What is a table variable?
A table variable is a memory resident structure that is visible only within the connection that declared the variable and is deallocated after the code which declared the variable completes.
What is a clustered primary key?
A clustered primary key, the default SQL Server behavior, causes SQL Server to store the table in sorted order according to the primary key.
When a clustered primary key is created on a table that is compressed, when is compression applied to the primary key?
When the table is rebuilt.
How is a unique constraint similar to a primary key?
Neither allows duplicates, though a unique constraint allows NULLs. A unique constraint treats NULLs as it does any other data value; if a unique constraint is defined on a single column, then a single row within the table is allowed to have a NULL within the column.
What is a default constraint?
A default constraint allows you to specify a value that is written to the column if the application does not supply a value. SQL SERVER WRITES THE DEFAULT VALUE TO A COLUMN ONLY IF THE APPLICATION DOES NOT SPECIFY THE COLUMN IN THE INSERT STATEMENT.
What is a check constraint?
A check constraint limits the range of values within a column.
How do check constraints at a column level differ from check constraints at a table level?
Column-level check constraints cannot reference any other column in the table; table-level check constraints can reference any column within a table, but not other tables.
What structure does SQL Server use to build and maintain indexes?
A balanced tree (B-tree). A B-tree is constructed of a root node that contains a single page of data, one or more optional intermediate level pages, and one or more optional leaf level pages.
How many bytes of data are in a SQL Server data page? How many can be used for actual data?
A data page is 8,192 bytes, 8,060 bytes can be used to store data.
If you are creating an index on a sparse column, what type of index should you use?
You should use a filtered index.
What is the maximum number of columns that can be used to define an index?
16
What is the maximum size of the index key?
900 bytes
What is a clustering key?
The column(s) defined for a clustered index.
What is special about a clustered index?
It causes SQL to arrange the data in the table according to the clustering key.
How many clustered indexes can you have for a table?
Only one, since a table can only be sorted one way.
What is a heap?
A table without a clustered index.
What does the leaf node of a clustered index correspond to; how does this compare to the leaf node of a heap?
In a clustered index, the leaf node is the actual data; in a heap, it is a forward pointer to the location of the row in the table's data pages.
When is the FILESTREAM_ON clause used?
When clustered indexes are crated on a table containing FILESTREAM data.
If you specify a different filegroup in the FILESTREAM_ON clause than where the FILESTREAM data is currently located, what happens?
All the FILESTREAM data will be moved to the newly specified filegroup during the creation of the clustered index.
What restrictions doe nonclustered indexes have?
Max size of 900 bytes in the index key, a maximum of 16 columns and a table is limited to 1,000 nonclustered indexes.
Where does the pointer at the leaf level of a nonclustered index point if a clustered index exists on the table; if one does not?
If a clustered index exists on the table, the leaf level of the nonclustered index points to the clustering key; if a clustered index does not exist, it points to the row of data in the table.
What is a covering index?
An index that is constructed such that SQL Server can completely satisfy queries by reading only the index.
What is the benefit of using the INCLUDE clause with indexes?
Included columns become part of the index only at the leaf level; values do not appear in root or intermediate levels and do not count against the 900 byte or 16 column restrictions.
What does the query optimizer do?
It is a component that decides whether or not to use an index to satisfy a query based on the distribution statistics that are stored for the index.
What is meant by the selectivity of an index?
The degree to which values in a column allow you to locate small sets of data; as the number of unique values within a column increases, so does the selectivity of an index. The query optimizer chooses the most selective indexes to satisfy queries.
What is a filtered index?
An index with a WHERE clause. Only the index keys matching the WHERE clause are added to the index, allowing you to build indexes that focus on the highly selective portions of the table.
What restrictions do filtered indexes have?
The must be a nonclustered index.
They cannot be created on computed columns.
Columns cannot undergo implicit or explicit data type conversion.
What is FILLFACTOR used for?
It is used to control the rate at which page splits occur; it specifies the percentage of free space that should be left on the leaf level of an index during creation or rebuild.
What is the PAD_INDEX option used for?
It causes the FILLFACTOR to be applied to the intermediate-level page(s) and the root page of an index.
What is the SORT_IN_TEMPDB option used for?
Normally, during index creation, the work tables SQL uses for sorting the values prior to building the B-tree are created in the same database as the index. The use of this option causes them to be created in the tempdb database.
What is the IGNORE_DUP_KEY option used for?
In indexes designated as unique, multi-row inserts with a duplicate in one row would cause the entire transaction to roll back; this option rejects only the row with a duplicate.
Index can be created either online or offline, how is this done and what does it mean?
It is done using WITH ONLINE = ON | OFF. When off, SQL locks the entire table, preventing any changes until the index is created. When on, SQL allows changes to the table during creation of hte index by using the version store within the tempdb database.
How to clustered and nonclustered index builds differ when done off-line.
When you build a clustered index offline, the table is locked and does not allow select statements or data modifications. If you build a nonclustered index offline, a shared table lock is acquired, which allows select statements but not data modification.
What versions of SQL Server 2008 support online index creation, rebuild or online restore?
Only SQL server 2008 enterprise.
What is a primary XML index?
A primary XML index is built against all the nodes within the XML column. The primary XML index is also tied to the table by maintaining a link to the corresponding row in the clustered index. Therefore, a clustered index is required before you can create a primary XML index.
What is a secondary XML index?
Secondary indexes can be created on PATH, VALUE, or PROPERTY. A primary XML index is first required, because secondary XML indexes are built against the data contained within the primary XML index.
What is a spatial index?
It is an index created against a spatial column that it types as either geometry or geography.
What is the decomposition process by which spatial data is converted from a 2D system to a linear structure?
Tessellation.
What is the BOUNDING_BOX parameter?
The BOUNDING_BOX parameter defines the maximum and minimum x, y coordinates that are considered when constructing the grid hierarchy and tessellating the rows of geometry data.
What are the three types of XML indexes that you can create?
PATH, VALUE and PROPERTY.
How do you defragment an index?
You use the ALTER INDEX statement.
What are the two options you can use when you defragment an index?
You can either REBUILD or REORGANIZE.
What does the REBUILD option in an ALTER INDEX statement do?
The REBUILD option rebuilds all levels of the index and leaves all pages filled according to the FILLFACTOR setting of an index. If you rebuild the clustered index, only the clustered index is rebuilt. However, rebuilding the clustered index with the ALL keyword also rebuilds all nonclustered indexes on the table. The rebuild of an index effectively re-creates the entire B-tree structure, so unless you specify the ONLINE option, a shared table lock is acquired, preventing any changes until the rebuild operation completes.
What does the REORGANIZE option in an ALTER INDEX statement do?
The REORGANIZE option removes fragmentation only at the leaf level. Intermediate-level pages and the root page are not defragmented during a reorganize. REORGANIZE is always an online pperation that does not incur any long-term blocking.
How do you disable an index?
ALTER INDEX { index_name | ALL }
ON <object>
DISABLE [ ; ]
What happens when an index is disabled?
When an index is disabled, the defi nition remains in the system catalog but is no longer used. SQL Server does not maintain the index as data in the table changes, and the index cannot be used to satisfy queries. If a clustered index is disabled, the entire table becomes inaccessible.
How do you re-enable an index that was disabled?
It must be rebuilt using the REBUILD option:
ALTER INDEX { index_name | ALL }
ON <object>
REBUILD [ ; ]
In SQL Server 2008, where are the contents of a full text catalog stored?
In the database; unlike previous versions, where it was stored in a directory on the operating system.
What does the ACCENT_SENSITIVITY option provide?
It allows you to configure whether the full text engine considers accent marks when building or querying a full text index.
What do you need to do if you change the ACCENT_SENSITIVITY option on a full text catalog?
You need to rebuild the full text indexes with the catalog.
What columns can be used to create a full text index?
CHAR
VARCHAR
XML
VARBINARY
What are word breakers?
Assemblies that locate breaks between words within the data being indexed for a full text index.
What are stemmers?
Stemmers conjugate verbs so that your queries can locate information even across multiple verb tenses.
What are stop words?
In the creation of a full text index, stop words are common words that you would not normally search upon (e.g. the, a, an).
How many full text indexes can a table or index view have?
Only one, though it can be created on multiple columns.
What is the CHANGE_TRACKING option for a full text index used for?
It determines how SQL maintains the index when underlying data changes are made. The options are AUTO, OFF or MANUAL.
Before you can create a full text index, what structure do you need to specify?
A full text catalog.
What do you need to specify to create a full text index on documents stored within a FILESTREAM?
SQL Server stores the documents within a VARBINARY(MAX) column with the FILESTREAM property enabled. In order to create a full text index, you need to also specify a type column that designates what type of document is stored in the VARBINARY(MAX) column to load the appropriate fi lter for the word breaker to use.
What columns can you create a full text index on?
CHAR/VARCHAR, XML, and VARBINARY.
What are the four commands that SQL Server uses to query full text?
CONTAINS
FREETEXT
CONTAINSTABLE
FREETEXTTABLE
What is the difference between CONTAINS and FREETEXT and CONTAINSTABLE and FREETEXTTABLE?
CONTAINS and FREETEXT return a True/False value used to restrict a result set, and CONTAINSTABLE and FREETEXTTABLE return a result set that can be used to extend query functionality.
Are all search terms used with full text Unicode strings or non-Unicode strings?
Unicode?
What happens if you pass a non-Unicode string to a full-text query?
If you pass in a non-Unicode string, the query still works, but it is much less effi cient because the optimizer cannot use parameter sniffi ng to evaluate distribution statistics on the full text index.
What features does the CONTAINS query allow you to search on?
Search word forms
Search for word proximity
Provide relative weighting to terms
How do CONTAINS AND FREETEXT differ in fuzzy searching?
It is the default in FREETEXT, while you have to specify that you want it in CONTAINS.
What are the two options you can use with FORMSOF?
INFLECTIONAL, which causes the full text search engine to consider word stems (e.g. searching for driven also searches for drove, drive, driving).
THESAURUS which produces synonyms for the search terms.
What type of file are Thesaurus files and where are they located?
XML; the FTDATA directory underneath your default SQL Server installation path.
What does ISABOUT perform?
ISABOUT performs proximity searches and it also applies weighting if the WEIGHT keyword and weighting value are supplied.
When is the thesaurus file used?
After it is defined, FREETEXT and FREETEXTTABLE use it automatically; CONTAINS and CONTAINTSTABLE use it if specified with the FORMSOF THESAURUS option.
What are the two set types that a thesaurus file contain?
A thesaurus can contain expansion sets or replacement sets. A replacement set defines a term or terms that are replaced within the search argument prior to the word breaker tokenizing the argument list. An expansion set defi nes a set of terms that are used to expand upon a search argument. When an expansion set is used, a match on any term within the expansion set causes SQL Server to retrieve the row.
What setting specifies whether the thesaurus is accent sensitive?
the diacritics setting.
Where are Stop lists contained in SQL 2008, how does this differ from SQL 2005?
In 2008, they are stored in the database. In 2005, they were stored in the FTDATA directory.
What are the options for populating a Full text index?
- FULL Reprocesses every row from the underlying data to rebuild the full text index completely
- INCREMENTAL Processes only the rows that have changed since the last population; requires a timestamp column on the table
- UPDATE Processes any changes since the last time the index was updated; requires that the CHANGE_TRACKING option is enabled for the index and set to MANUAL
How do you reload the English thesaurus file?
EXEC sys.sp_fulltext_load_thesaurus_file 1033
How do you manage thesaurus files?
You edit the language specific file that is contained in the FTDATA directory for the instance.
What commands do you use to build a list of stop words for a full text index?
CREATE FULLTEXT STOPLIST and ALTER FULLTEXT STOPLIST
What is the process for partitioning a table, index or indexed view?
1. Create a partition function.
2. Create a partition scheme mapped to a partition function.
3. Create the table, index or indexed view on the partition scheme.
What data types cannot be used with partition functions?
You cannot use text, ntext, image, xml, varbinary(max), varchar(max), or any CLR data types.
What is the maximum number of partitions allowed for a table?
The maximum number of partitions for a table is 1,000.
What is the maximum number of boundary points allowed for a partition function?
The maximum number of boundary points for a partition function is 999.
What is the AS clause used for in a partition function?
The AS clause allows you to specify whether the partition function you are creating is RANGE LEFT or RANGE RIGHT.
What is the FOR VALUES clause used for in a partition function?
It is used to specify the boundary points for the partition function. If the partition function is created as RANGE LEFT, then the boundary point is included in the left partition. If the partition function is created as RANGE RIGHT, then the boundary point is included in the right partition.
Where are NULL values stored in a partition?
They are always stored in the leftmost partition until you explicitly specify null as a boundary point and use the RANGE RIGHT syntax, in which case nulls are stored in the rightmost partition.
How do you partition an existing object after it has been populated with data?
To partition an existing table, you need to drop the clustered index and re-create the clustered index on the partition scheme. To partition an existing index or indexed view, drop the index and re-create the index on a partition scheme. You will want to be very careful when partitioning existing objects that already contain data, because implementing the partition will cause a signifi cant amount of disk input/output (I/O).
What happens if more filegroups are included in the partition scheme than there are partitions?
Any excess filegroups will not be used to store data unless explicitly specified by using the ALTER PARTITION SCHEME command.
If you specify the ALL keyword when creating a partition scheme, what is the maximum number of filegroups you can specify?
1
Can you create a new fi legroup at the same time that you are creating a partition scheme?
No. Any filegroups that you specify in the CREATE PARTITION SCHEME statement must already exist in the database.
How do you create a partitioned table or indexed view?
Instead of using the ON clause to specify a filegroup, you specify a partition scheme.
What property must be set to use a computed column as a partitioning key?
The computed column must be persisted.
Which operators are used to add or remove boundary points from a partition function?
The SPLIT operator is used to introduce a new boundary point. The MERGE operator is used to remove a boundary point.
Which operator is used to move partitions between tables?
The SWITCH operator is used to move partitions between tables.
What are the two purposes of the NEXT USED clause?
1. It adds a new filegroup to the partition scheme, if the specifi ed fi legroup is not already part of the partition scheme.
2. It marks the NEXT USED property for a filegroup (The filegroup that is marked with the NEXT USED flag is the filegroup that contains the next partition that is created when a SPLIT operation is executed.).
What is aligned storage?
When a table and all its indexes use the same partition function and the same partition scheme. This ensures that if a single partition is backed up or restored, the data and corresponding indexes are kept together in a single unit.
What requirements does the SWITCH operator have?
-- The data and index for the source and target tables must be aligned.
-- Source and target tables must have the same structure.
-- Data cannot be moved from one filegroup to another.
-- Two partitions with data cannot be exchanged.
-- The target partition must be empty.
-- The source or target table cannot participatie in replication.
-- The source or target tables cannot have full text indexes or a FILESTREAM data type defined.
If you are exporting data using BCP, the account that BCP is running under needs what permissions?
Only SELECT
If you are importing data using BCP, the account that BCP is running under needs what permissions?
SELECT, INSERT and ALTER TABLE
In BCP, what does the first argument specify?
The table or query that BCP operates upon.
In BCP, what does the second argument specify?
Can be set to in, out or queryout. When in, BCP imports the contents of the file specified. When out, BCP exports the entire contents of the table into the file specified.
In BCP, what does the third argument specify?
The file that is the source or target of the BCP command.
How do you use queryout with BCP?
You replace the name of the table with a query delimited by double quotes.
What do the -n and -c switches specify in BCP?
They are mutually exclusive. -n specifies that the data in the files is in the native format of SQL Server. The-c switch specifies that the data is a character format.
In BCP, what does the -S switch specify?
The instance name to connect to.
In BCP, what does the -T switch specify?
designates a trusted connection and BCP uses the windows credentials of the account that is executing the BCP command to connect.
In BCP, what does the -U switch specify?
login name
In BCP, what does the -P switch specify?
password
In BCP, what does the -h switch specify?
enforces check constraints and fire triggers during the import
How does the BULK INSERT command differ from BCP?
BULK INSERT cannot export data and is a T-SQL command, thus does not require the instance name or login credentials.
The Import and Export wizard is based on which feature of SQL?
SSIS
What three data types can the Import and Export Wizard not work with?
hierarchy, geography and geometry
What permission is required by BCP to use the -h option other than SELECT and INSERT?
ALTER TABLE
Where are all the objects for Policy Based Management stored?
Within the msdb database.
How can you get a list of the facets available?
By querying the dbo.syspolicy_management_facets table.
What are the five objects that are used within Policy Based Management?
Facets, conditions, policies, policy targets, and policy categories.
What are the allowed execution modes for a policy?
The policy execution modes are On demand, On schedule, On change, Log only, and On change, prevent.
Which object has a property that allows you to mandate checking for all databases on an instance?
Policy categories allow you to mandate checking of all databases within an instance.
How many facets can be checked within a single condition?
A condition can be defi ned on only one facet.
How many conditions can be checked within a single policy?
A policy can check only a single condition.
What is a facet?
Facets define the type of object or option to be checked, such as database, Surface Area and login.
If you define a condition using the advanced editor, can a policy that incorporates the condition be scheduled?
No, it must be executed manually.
What are the four execution modes that a policy can be set for?
-- On demand Evaluates the policy when directly executed by a user
-- On change, prevent Creates data defi nition language (DDL) triggers to prevent a change that violates the policy
-- On change, log only Checks the policy automatically when a change is made using the event notification infrastructure
-- On schedule Creates a SQL Server Agent job to check the policy on a defined schedule
What effect does the policy category mandate property have when applied to a databse?
When a policy category is set to Mandate and a sysadmin subscribes the instance to a policy category, all databases that meet the target set are controlled by the policies within the policy category. A policy subscription to a policy category set to Mandate cannot be overridden by a database owner.
What is the mandate property setting for the default category?
mandate enabled.
What security context do all backup execute under?
Under the SQL Server service account.
What databases can a sysadmin backup?
All the databases in an instance.
What databases can a db_owner backup?
Only their databases.
What database role can you add a user to in order to allow them to back up a database while preventing any other access to the database?
db_backupoperator
What are the four types of backups you can perform in SQL Server 2008?
Full
Differential
Transaction Log
Filegroup
What does a Full Backup contain?
All pages within a database that contain data; pages that do no contain data are no included in the backup.
What is the limiting factor for the speed of a backup?
The performance of the device where the backup is being written.
What are the backup procedure steps that SQL Server performs?
1. Locks the database, blocking all transactions
2. Places a mark in the transaction log
3. Releases the database lock
4. Extracts all pages in the data files and writes them to the backup device
5. Locks the database, blocking all transactions
6. Places a mark in the transaction log
7. Releases the database lock
8. Extracts the portion of the log between the marks and appends it to the backup
What are the only operations not allowed during a backup?
adding or removing a database file
shrinking a database
What are the only two parameters required for a backup?
The name of the database and the backup device.
What happens when you specify more than one backup device? What is the max number you can have?
SQL Server stripes the backup across each of the devices specified. The max is 64.
What effect does the MIRROR TO clause have on a backup?
When you include the MIRROR TO clause, SQL Server retrieves the page once from the database and writes a copy of the page to each backup mirror.
What requirements do mirrored backups have?
-- All backup devices must be of the same media type.
-- Each mirror must have the same number of backup devices.
-- WITH FORMAT must be specified in the backup command.
Why is a compressed backup always worth the processing overhead?
The amount of time saved far exceeds the overhead associated with the compression operation.
What do the INIT/NOINIT options of a BACKUP command control?
Whether an existing backup file is overwritten or appended to.
NOINIT = append
INIT = overwrite
What does the CHECHSUM option of a BACKUP command control?
When CHECKSUM is specified, SQL Server verifies the page checksum, it if exists, before writing the page to the backup. Also, a checksum is calculated for the entire backup that can be used to determine if the backup has been corrupted.
What is the default behavior for errors encountered during a backup?
STOP_ON_ERROR - if an invalid page checksum is encountered during backup, the backup terminates with an error.
How do you continue to backup past an invalid checksum?
Use the CONTINUE_PAST_ERROR option.
What is Log Sequence Number (LSN)?
A unique number assigned to each row of a transaction log. It begins with one and increments to infinity, never repeating.
What does the active portion of the transaction log contain? The inactive?
The active portion contains all changes that have not yet been committed. The inactive portion contains all the changes that have been committed to the database.
What happens if an LSN gap is introduced into the transaction log backup?
You must create a full backup before you can start backing up the transaction log.
What does a differential backup capture?
All extents that have changed since the last full backup.
How are the changes since the last full backup tracked?
By using a special page in the header of a database called the Differential Change Map (DCM). A full backup zeroes out the contents of the DCM.
When an extent is changed, how does the change appear in the DCM?
The bit corresponding to the extent is set to 1.
What does the COPY_ONLY option in a backup allow?
It allows you to create a backup but does not affect the database state or set of backups in production. e.g. a full backup with COPY_ONLY set does not zero out the DCM and a transaction log backup with COPY_ONLY does not remove transactions from the transaction log.
What is a Filegroup backup?
It allows you to target a portion of the database to be backed up (reducing time and the footprint of the backup).
What is a partial backup?
Partial backups back up the primary filegroup, all read/write filegroups and any explicitly specified read-only filegroups. In this way, you eliminate backing up read-only filegroups, which would not change.
How do you perform a partial backup?
By specifying the READ_WRITE_FILEGROUPS option:
BACKUP DATABASE database_name READ_WRITE_FILEGROUPS [,<file_filegroup_list>] TO <backup_device>
What command to you execute to have SQL Server detect and quarantine corrupted pages?
ALTER DATABASE <dbname> SET PAGE_VERIFY CHECKSUM
Is there a limit to the number of corrupt pages in a database?
Yes, SQL puts a limit of 1000 corrupt pages on a database. Once you reach the limit, the database is taken offline and places it in a suspect state to protect it from further damage.
What are maintenance plans and what tasks are supported?
They provide a mechanism to graphically create job workflows that support common administrative functions. The tasks supported are:
-- Backing up of databases and transaction logs
-- shrinking databases
-- re-indexing
-- updating of statistics
-- performing consistency checks
What are maintenance plans based on?
SSIS
What is a service master key?
A service master key is created automatically the first time than an instance is started. It is regenerated each time that you change the SQL Server service account or password.
How do you backup the service master key?
BACKUP SERVICE MASTER KEY TO FILE = 'path_to_file'
ENCRYPTION BY PASSWORD = 'password'
What are database master keys (DMKs)?
DMKs are created prior to the creation of a certificate, symmetric key or asymmetric key. A DMK is the root of the encryption hierarchy in a database.
How do you backup a DMK?
BACKUP MASTER KEY TO FILE = 'path_to_file'
ENCRYPTION BY PASSWORD = 'password'
What must you do before you backup the DMK?
The DMK must be open:
USE <database name>;
OPEN MASTER KEY DECRYPTION BY PASSWORD = '<SpecifyStrongPasswordHere>';
By default, what is the DMK encrypted with?
The service master key.
How do you backup just the public key of a certificate?
BACKUP CERTIFICATE certname TO FILE = 'path_to_file'
How do you backup a certificate (both the private and public keys)?
BACKUP CERTIFICATE certname TO FILE = 'path_to_file'
[ WITH PRIVATE KEY
(FILE = 'path_to_private_key_file' ,
ENCRYPTION BY PASSWORD = 'encryption_password'
[ , DECRYPTION BY PASSWORD = 'decryption_password' ] ) ]
How do you validate a backup?
RESTORE VERIFYONLY FROM <backup device>
What checks does SQL perform when a backup is validated?
-- Calculates a checksum for the backup and compares to the checksum stored in the backup file
-- Verifies that the header of the backup is correctly written and valid
-- Transits the page chain to ensure that all pages are contained in the database and can be located
What does the NO_TRUNCATE option allow?
It allows you to backup the transaction log without writing to the master data file.
Where is the LSN of the last modification stored at the database level, the data file level and the data page?
At database level, the LSN of the last modification to the db is stored in the header of the master data file. At data file level, the LSN of the last change to a page within the file is stored in the header of the data file. At data page level, the LSN of the last change to the data page is stored.
What is a dirty page?
A modified page in the buffer pool. Every dirty page tracks the LSN in the transaction log that corresponds to the change that modified the page in the buffer pool.
What happens to dirty pages when SQL server executes a checkpoint?
All dirty pages in the buffer pool are written out to the data files.
What happens during the checkpoint process?
During the checkpoint process, SQL Server compares the LSN of the dirty page in the buffer pool to the LSN of the data page on disk. If the LSN of the data page on disk is equal to or less than the LSN of the dirty page in the buffer pool as well as equal to or less than the LSN for the data fi le, the page on disk is overwritten with the page from the buffer pool. If the LSN of the dirty page is greater than the page on disk or the data fi le containing the page, the page in the buffer pool is overwritten by the page on disk. When the checkpoint process fi nishes writing dirty pages to the data fi les, the largest LSN written to each fi le is written into the header of the fi le. In addition, the largest LSN written across the entire checkpoint process is written to the header of the master data fi le. SQL Server ensures that the LSN for every page within a fi le is equal to or less than the LSN for the fi le and that the LSN for every file within a database is equal to or less than the LSN for the database. The fi nal step in the process is to clear the fl ag on each dirty page affected by the checkpoint that designates the page has changed.
What are the two phases of restart recover. When does restart recovery take place?
UNDO and REDO. It takes place when SQL server is started.
What happens during REDO phase of restart recovery?
All committed transactions in the transaction log are flushed to disk.
What happens during the UNDO phase of restart recovery?
During UNDO, which occurs after REDO, the transaction log is examined and any transactions that are still open are invalidated, ensuring that they cannot be written to disk.
What is rolling forward?
After UNDO phase completes, the database is rolled forward: SQL Server reads the last LSN recorded in the transaction log, increments the LSN and writes the new LSN into the header of every data file within the database, ensuring that transactions older than the roll-forward point cannot be written to the data files.
What do all restore sequences begin with?
Either a full backup or filegroup backup.
After the database or filegroup being restored has been brought back online, can you apply additional differential or transaction log backups to the database?
No.
During a RESTORE command, what happens if the database does not already exist within the instance?
It is created.
What does the REPLACE option during a RESTORE command control.
Forces the restore over the top of an existing database.
Why does a restore take about 30% longer than the backup?
SQL is optimized to backup and can pull pages into the backup regardless of order. During a restore, the pages must be placed back into the database in sequential order.
What do the first pages within a database store?
The structural information about the db, such as the list of pages allocated to the db.
During a RESTORE command, what does the RECOVERY option provide?
After the RESTORE operation completes, the db is online and accessible.
During a RESTORE command, what does the NORECOVERY option provide?
The RESTORE operation completes, but the database is left in a RECOVERYING state, such that subsequent differential and/or transaction log backups can be applied.
During a RESTORE command, what does the STANDBY option provide?
Allows you to issue SELECT statements against the database while still issuing additional differential and/or transaction log restores. If you restore a db with the STANDBY option, an additional file is created to make the db consistent as of the last restore that was applied.
During a RESTORE command, what does the MOVE option provide?
It allows you to change the location of db files during the restore.
What is the first step in any restore operation?
You should issue a transaction log backup against the original db. This is referred to as backing up the tail of the log.
What is the syntax for restoring a full or differential backup?
RESTORE DATABASE { database_name | @database_name_var }
[ FROM <backup_device> [ ,...n ] ]
[ WITH {[ RECOVERY | NORECOVERY |
STANDBY = {standby_file_name | @standby_file_name_var } ]
| , <general_WITH_options> [ ,...n ]
| , <replication_WITH_option>
| , <change_data_capture_WITH_option>
| , <service_broker_WITH options>
| , <point_in_time_WITH_options—RESTORE_DATABASE>
} [ ,...n ]
]
<general_WITH_options> [ ,...n ]::=
--Restore Operation Options
MOVE 'logical_file_name_in_backup' TO 'operating_system_file_name'
[ ,...n ] | REPLACE | RESTART | RESTRICTED_USER
What is the syntax for restoring a transaction log backup?
RESTORE LOG { database_name | @database_name_var }
[ <file_or_filegroup_or_pages> [ ,...n ] ]
[ FROM <backup_device> [ ,...n ] ]
[ WITH {[ RECOVERY | NORECOVERY |
STANDBY = {standby_file_name | @standby_file_name_var } ]
| , <general_WITH_options> [ ,...n ]
| , <replication_WITH_option>
| , <point_in_time_WITH_options—RESTORE_LOG> } [ ,...n ] ]
<point_in_time_WITH_options—RESTORE_LOG>::=
| { STOPAT = { 'datetime' | @datetime_var }
| STOPATMARK = { 'mark_name' | 'lsn:lsn_number' }
[ AFTER 'datetime' ]
| STOPBEFOREMARK = { 'mark_name' | 'lsn:lsn_number' }
[ AFTER 'datetime' ]
During a transaction log restore, what does the STOPAT command allow?
Allows you to specify a date and time to which SQL Server restores.
During a transaction log restore, what do the STOPATMARK and STOPBEFOREMARK commands allow?
Allow you to specify either an LSN or a transaction log MARK to use for the stopping point in a restore operation.
How does the primary filegroup state affect the state of the db.
The state of a db equals the state of the primary filegroup.
To take advantage of the online restore capabilities of SQL Server 2008 Enterprise, what type of restores can you do?
Either a file or filegroup restore, which does not include the primary filegroup. A full restore affects the entire database, which includes the primary filegroup (which sets the state of the db).
What do you do if page corruption occurs in an index?
Drop and recreate the index.
What are the requirements for a page restore?
-- The database must be in either the Full or Bulked-logged recovery model.
-- You must be able to create a transaction log backup.
-- A page restore can apply only to a read/write filegroup.
-- You must have a valid full, file, or filegroup backup available.
-- The page restore cannot be executed at the same time as any other restore operation.
What is the syntax to restore a page?
RESTORE DATABASE database_name
PAGE = 'file:page [ ,...n ]' [ ,...n ]
FROM <backup_device> [ ,...n ]
WITH NORECOVERY
What are the steps to restore a page to a database?
1. Retrieve the PageID of the damaged page.
2. Using the most recent full, file, or filegroup backup, execute the following command:
RESTORE DATABASE database_name
PAGE = 'file:page [ ,...n ]' [ ,...n ]
FROM <backup_device> [ ,...n ]
WITH NORECOVERY
3. Restore any differential backups with the NORECOVERY option.
4. Restore any additional transaction log backups with the NORECOVERY option.
5. Create a transaction log backup.
6. Restore the transaction log backup from step #5 using the WITH RECOVERY option.
What is a best effort restore?
If the backup media is damaged, SQL server will continue past the source of damage and continue restoring as much of the database as possible. After the restore, the db is set to EMERGENCY mode.
What do you need to specify to restore from backup media that has been damaged?
CONTINUE_AFTER_ERROR for a RESTORE DATABASE or RESTORE LOG command.
What versions of SQL is database snapshot available?
Only SQL Server 2008 Enterprise
What happens if you create a database snapshot against a database with FILESTREAM data?
The FILESTREAM filegroup is disabled and not accessible.
What is the syntax to create a database snapshot?
CREATE DATABASE database_snapshot_name
ON
(NAME = logical_file_name,
FILENAME = 'os_file_name') [ ,...n ]
AS SNAPSHOT OF source_database_name
What are the requirements to create a database snapshot?
-- You must include an entry for each data file specified in the source database
--the logical name of each file must match the name in the source database exactly
What restrictions exist for a database snapshot?
-- You can’t back up, restore, or detach a Database Snapshot.
-- The Database Snapshot must exist on the same instance as the source database.
-- Full text indexes are not supported.
-- FILESTREAM is not supported, and any FILESTREAM data is inaccessible through the Database Snapshot.
-- You can’t create a Database Snapshot against a system database.
-- You can’t drop, restore, or detach a source database that has a Database Snapshot created against it.
-- You can’t reference fi legroups that are off-line, defunct, or restoring.
How much space on disk does SQL Server allocate for a database snapshot?
SQL Server takes advantage of sparse files--essentially an entry in the file allocation table and consumes almost no space on disk. As data is added to the file, the file automatically grows on disk.
How does a database snapshot act from an application perspective.
It looks and acts like a read-only database to any queries.
How much data does a database snapshot contain at the time of creation?
None.
How many pages are in an extent?
8 pages; SQL Server reads and writes extents.
What is the copy-on-write mechanism?
The means by which SQL Server manages changes that occur within the source database of a database that has a database snapshot. The first time a modification is made to a data page within an extent occurs in the source db, SQL Server copies the before image of the extent to the Database snapshot.
What is the max size of a database snapshot?
The amount of data that existed in the source database at the time of creation.
What is a database revert?
A special category of restoring data when you have a database snapshot. If you need to revert only a row or portion of a db, you can use and INSERT, UPDATE, DELETE or MERGE statement. SQL Server also allows you to revert the entire db using the snapshot, if necessary.
What is the syntax to revert a db from a database snapshot?
RESTORE DATABASE <database_name> FROM DATABASE_SNAPSHOT = <database_snapshot_name>
What restrictions are there on reverting a source database?
-- Only a single Database Snapshot can exist for the source database.
-- Full-text catalogs on the source database must be dropped and then re-created after the revert completes.
-- Because the transaction log is rebuilt, the transaction log chain is broken.
-- Both the source database and Database Snapshot are off-line during the revert process.
-- The source database cannot be enabled for FILESTREAM.
What two features are incompatible with Database snapshots?
FILESTREAM and full text indexes.
Prior to reverting a database using a Database snapshot, what must you do?
You must drop all database snapshots except the database snapshot being used as the source for the RESTORE command.
What is a job step?
The execution elements within a job.
What type of job steps can be executed?
What is the default security context for a job step?
It corresponds to the login that is set as the owner of the job. You can also override the security context by specifying a proxy account that the SQL Server agent uses for the job step based on credentials assigned to the proxy account.
What options can a job step be configured with?
What control flow options are available for a job?
Quit job reporting success
Quit job reporting failure
Go to next step
Go to a specific step number
What are the three logging options that are available to a job?
Log to a file that is overwritten each time, append to a file or log to a table (not recommended due to overhead).
In addition to any logging configured for a job step, what log information is gathered?
SQL Server logs information into the dbo.sysjobhistory table in the msdb database for each job step that is executed within the job. Some of the information recorded is:
-- job step
-- status
-- execution date and time
-- duration
--if an error occurs, the number, severity, and text of the last error message generated
If a job fails, where can you look to diagnose the problem?
The first place to look is in the job history, which can be accessed from SQL Server Management Studio (SSMS) by right-clicking a job and selecting View History. You can also look in the logging files that are configured for each job step. In some cases, you might find additional information in the Microsoft Windows event logs.
What is an Operator for a job?
An alias for a person, group or device. Operators are used to send notifications when jobs fail or an alert is generated. For each operator, you specify a name along with contact information.
What are the three types of SQL Server Agent alerts?
-- A SQL Server event
-- A performance condition alert
-- A windows management instrumentation (WMI) event
What are the two response actions that can be configured for an alert?
You can have an alert send a notification or execute a job in response to the alert condition.