SQL Fundamentals

Download as pdf or txt
Download as pdf or txt
You are on page 1of 259

SQL Server Fundamentals

CERTIFIED STUDENT CURRICULUM


SAGE LEARNING SERVICES
Curriculum Version 2.0
N
o
t

f
o
r

R
e
s
a
l
e

o
r

R
e
p
r
o
d
u
c
t
i
o
n
NOTICE
This document and the Sage ERP MAS 200 software may be used only in accordance with the accompanying Sage ERP
MAS 200 End User License Agreement. You may not use, copy, modify, or transfer the Sage MAS 90 and 200 software
or this documentation except as expressly provided in the license agreement.
Visit our website at www.SageU.com, or call 1-800-944-4299 to learn about training classes that are added throughout
the year.
Information in this document is intended solely as general information with respect to common business issues and is
not to be construed as professional advice. It is always best to consult a tax or accounting professional for all tax and
account related questions. THE INFORMATION HEREIN IS PROVIDED AS IS AND ALL WARRANTIES ARE
EXPRESSLY DISCLAIMED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY: OF
MERCHANTABILITY; OF FITNESS FOR ANY PARTICULAR PURPOSE; OF NON-INFRINGEMENT OF ANY
PROPRIETARY RIGHT OF ANY THIRD PARTY IN ANY COUNTRY; OTHERWISE ARISING OUT OF ANY
PRODUCT, PROPOSAL, SPECIFICATION OR SAMPLE; AND ANY WARRANTY THAT THE DOCUMENT IS
ERROR FREE. No license, express, implied, by estoppel or otherwise, to any intellectual property right is granted by
this document. Sage Software may make changes to the information in this document at any time, without notice.
Recipient is solely responsible for assessing the suitability of the information and assumes all risk of use.
2010 Sage Software, Inc. All rights reserved. Sage, the Sage logos, and the Sage product and service names mentioned
herein are registered trademarks or trademarks of Sage Software, Inc., or its affiliated entities. All other trademarks are
the property of their respective owners.
07/2010
SQL Server Fundamentals
Certified Student Course Curriculum - Version 2.0 Page i
Copyright 2010 Sage Software, Inc. All rights reserved.
Contents
Welcome and Introduction..................................................... 1
Sage Online Website ............................................................. 3
Microsoft SQL Server Overview........................................... 4
About SQL Server ................................................................. 5
Database Basics................................................................... 10
Security................................................................................ 17
Using the SQL Server Interface .......................................... 18
Planning a SQL Server Installation .................................... 22
Hardware Considerations .................................................... 23
Upgrade Considerations ...................................................... 27
Challenge Questions - Part I................................................ 29
Installing and Registering Microsoft SQL Server ............. 30
Installing Microsoft SQL Server ......................................... 31
Adding and Registering a New SQL Server........................ 56
Adding a New SQL Server Group....................................... 60
Logging Onto SQL Server................................................... 62
Lab Exercise - Installing and Registering Microsoft SQL
Server................................................................................... 64
Challenge Questions - Part II .............................................. 65
Configuring SQL Server ...................................................... 66
Configuring SQL Server Properties .................................... 67
Challenge Questions - Part III ............................................. 79
Lab Exercise - Configuring the SQL Server Properties ...... 80
Exploring and Maintaining Your Data............................... 81
Viewing Databases Components......................................... 82
Viewing and Configuring Database Properties ................... 86
Creating a Table .................................................................. 96
Running Queries................................................................ 102
Working with Query Execution Plans............................... 107
Challenge Questions - Part III ........................................... 109
Lab Exercise - Viewing Database Properties .................... 110
Certified Student Course Curriculum - Version 2.0 Page ii
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals
Lab Exercise - Working with Queries ............................... 111
Managing Your Databases.................................................. 112
Using the Management Options ........................................ 113
Policy Management ........................................................... 114
Data Collection .................................................................. 115
Resource Governor ............................................................ 116
Maintenance Plans ............................................................. 117
SQL Server Logs ............................................................... 118
Database Mail .................................................................... 121
Challenge Questions - Part IV........................................... 123
Lab Exercise - Exploring the Management Node Options 124
Understanding the SQL Server Agent............................... 125
Using the SQL Server Agent ............................................. 126
Understanding Jobs............................................................ 128
Understanding Alerts ......................................................... 135
Understanding Operators ................................................... 138
Using the Job Activity Monitor ......................................... 142
Viewing SQL Server Agent Properties.............................. 144
Challenge Questions - Part V............................................. 147
Lab Exercise - Working with SQL Server Agent .............. 148
Optimizing and Fine-Tuning Your Databases.................. 149
Using Microsoft SQL Server Profiler ................................ 150
Using the Database Engine Tuning Advisor...................... 155
Monitoring Performance.................................................... 159
Monitoring Activity ........................................................... 164
Dynamic Management Views............................................ 167
SQL Server Reports ........................................................... 169
Other Performance Management Tools............................. 171
Challenge Questions - Part VI ........................................... 172
Lab Exercise - Monitoring Performance and Activity....... 173
Certified Student Course Curriculum - Version 2.0 Page iii
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals
Backing Up and Restoring Databases................................ 174
Backing Up a Database...................................................... 175
Restoring a Database ......................................................... 181
Attaching a Database ......................................................... 185
Transferring and Copying Databases................................. 187
Setting Database Options and Filegrowth Settings............ 188
Challenge Questions - Part VII.......................................... 192
Lab Exercise - Creating a Backup and Restore ................. 193
Working with Maintenance Plans...................................... 194
Creating Maintenance Plans .............................................. 195
Challenge Questions - Part VIII......................................... 204
Lab Exercise - Creating a Maintenance Plan..................... 205
Understanding SQL Server Integration Services............. 206
Overview of SQL Server Integration Services .................. 207
Developing Packages Using SSIS ..................................... 209
Challenge Questions - Part IX........................................... 227
Disaster Recovery................................................................ 228
Planning for Disaster Recovery ......................................... 229
High Availability Options.................................................. 232
Challenge Questions - Part X............................................. 238
Appendix A Challenge Answers...................................... 240
Appendix B Troubleshooting .......................................... 245
Appendix C Resources and References .......................... 251
Certified Student Course Curriculum - Version 2.0 Page iv
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals
Certified Student Course Curriculum - Version 2.0 Page 1
Copyright 2010 Sage Software, Inc. All rights reserved.
Lesson 1
Sage SQL Server Fundamentals
Welcome and Introduction
10
Welcome to the Sage SQL Server Fundamentals training class. This course is divided
into discussions of concepts, activities, and labs. The curriculum is designed to be
taught by a Sage Certified Trainer and is not intended for use as a self study guide.
Your Sage ERP product is designed to run using Microsoft SQL Server. By
understanding how Microsoft SQL Server works, implementing and supporting Sage
ERP will become easier and more efficient.
This class will teach you the basics of Microsoft SQL Server and focus on the SQL
tools that you should be familiar with when implementing Sage ERP for your client.
Each of these tools is an important component of Microsoft SQL Server.
This class is intended to help you meet the following objectives:
Learn about Microsoft SQL Server and its key benefits and features.
Learn how to plan for a successful installation of SQL Server.
Learn about installing and configuring SQL Server.
Learn how to explore and query data in your databases.
Learn how to maintain your databases.
Learn how to optimize and fine-tune your databases.
Learn how to back up and restore your databases.
Learn how to create maintenance plans.
Learn how to develop SQL Server Integration Services packages.
Learn about disaster recovery plans.
Sage SQL Server Fundamentals Welcome and Introduction
Page 2 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Welcome and Introduction (continued)
0
How to Use This Curriculum
The following table describes the conventions used in this curriculum.
Convention Explanation
Step numbers versus
activity numbers
Step numbers are not part of an activity and are
intended to provide you with the steps typically
used to complete a task. Activity numbers appear
in bold and are completed in class.
Italic font in an activity Items that are part of an activity and appear in an
italic font indicate you need to select a task or
perform a specific action to complete the step (for
example, click OK).
Courier font in an
activity
Items that are part of an activity and appear in a
courier font indicate information you should enter
(for example, at the Customer No. field, enter
01-ABS).
In a bulleted list, the key bullet style emphasizes
key information you should know regarding the
topic discussed.
Certified Student Course Curriculum - Version 2.0 Page 3
Copyright 2010 Sage Software, Inc. All rights reserved.
Sage SQL Server Fundamentals Welcome and Introduction
Sage Online Website
1
Because technology changes rapidly, Sage ERP documentation is continually
updated. Sage provides an online tool to help you find the latest product information
and to present issues and answers.
To ensure you have the latest information for your specific Sage ERP product, refer to
the Sage Software Online website at:
www.sagesoftwareonline.com
Note: The Sage Software Online website is dynamic and is continually improving;
therefore, information displayed through this curriculum may differ.
Activity
1. Log on to Sage Software Online now by opening your web browser and accessing
www.sagesoftwareonline.com.
2. Log on with the user ID and password provided by your instructor.
3. If a Security window displays, review the Non-Disclosure Agreement to ensure
proprietary information related to Sages operations is kept confidential and
accept the agreement.
4. Click the Support option and then click the link for your specific Sage ERP
product on the Customer Support page.
Page 4 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Lesson 2
SQL Server Fundamentals
Microsoft SQL Server Overview
21
Microsoft SQL Server is a critical piece of your SQL-based Sage ERP product. You
will learn about fundamental SQL Server information to help you better understand
the power of using SQL Server with your Sage ERP product. You will also learn
about the key benefits of using SQL Server as well as database basics, security, and
maneuvering the SQL Server interface.
The topics in this lesson include:
About SQL Server
Database Basics
Security
Using the SQL Server Interface
Certified Student Course Curriculum - Version 2.0 Page 5
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals About SQL Server
About SQL Server
1
What is SQL?
The Structured Query Language (SQL) is a database computer language
developed by IBM in the 1970s.
In the late 1970s, other companies started to develop similar products.
The goal of SQL Server was to come up with a standardized language for creating
relational databases to overcome different proprietary languages.
It was first named SEQUEL, but was later renamed to SQL.
- SQL Server versions 1.0 through 6.5 were Sybase dependent versions.
- SQL Server version 7.0 was the first Sybase independent version.
- SQL Server version 2000 offered multi-instance, detailed collation, and add-
on technologies, such as SQLXML, Notification Services, Reporting
Services, and 64-bit support.
- SQL Server 2005 introduced several editions: Enterprise, Standard,
Workgroup, and SQL Express. Additionally, many technological additions
were added.
- SQL Server 2008 editions include the following:
Enterprise edition: Targets enterprise workloads that need redundancy.
Standard edition: An affordable option for small and medium-sized
organizations.
Note: The Enterprise and Standard editions include Business Intelligence (BI);
however, the Standard edition does not include some advanced analytical
components.
Workgroup and Web editions: Are suitable for small organizations and
include Integration Services and Reporting Services only.
Express edition: Is a free, easy-to-use lightweight version that supports local
reporting and Reporting Services only.
Compact edition: Is a free, limited functionality in-process version and is
ideal for mobile devices or low-footprint applications with no multi-user
requirements.
SQL Server 2008 R2 includes:
- Self-service BI (PowerPivot)
- StreamInsight
- Substantial Reporting Services enhancements
- Report Builder 3
- Data-tier applications
- SQL Server utility
SQL Server Fundamentals About SQL Server
Page 6 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
About SQL Server (continued)
1
The SQL language was designed to use English commands such as Open, Close,
Select, and Update to instruct the database to perform certain actions.
- Example:

This command select all information from the tarcustomer table where the
record has a companyID equal to SOA.
There are many different versions of SQL on the market today.
- A few examples are BTRIEVE, Oracle, and Pervasive.
- Each company has a slightly different dialect.
- Most SQL Server database vendors support all or a subset of the ANSI SQL
standards, but typically extend the standards to leverage features within their
own implementation.
Microsoft SQL Server was introduced in 1990 for the Microsoft OS/2 platform.
- Later developed for the Microsoft Windows NT platform following the intial
release.
- The Microsoft SQL Server database engine runs as a service on several
Microsoft operating systems.
- The SQL Server service is responsible for the operation of the server instance.
At a lower level, there are SQL Server components that process all Transact-
SQL statements, allocate computer resources efficiently, and enforce business
rules.
Transact-SQL was provided with Microsoft SQL Server to allow communication
between an application and an instance of SQL Server. This language is used for
querying the database.
SQL Server conforms to the ANSI-92 entry level standard.
The SQL Server database platform can be used for online transaction processing
(OLTP), e-commerce, and data warehousing programs. It can also be used for
business intelligence for analysis, data integration, and reporting. For more
information, see Core Components of Microsoft SQL Server on page 8.
Certified Student Course Curriculum - Version 2.0 Page 7
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals About SQL Server
About SQL Server (continued)
1
Microsoft SQL Server Management Studio is one of the tools provided by the
SQL Server client installation that allows you to manage the SQL Server services
on your system. For more information, see Using the Management Options on
page 113 and Using the SQL Server Agent on page 126.
- It is not included with the Express edition.
- It is the user interface management console for managing all components of
your databases.
- Through this tool, you can also add, change and delete databases, create
imports and exports, schedule tasks, perform backups and restores, manage
security, and perform database maintenance.
Key Benefits of SQL Server
The following is a list of some of the key benefits of SQL Server:
Improves data retrieval and transaction processing
Schedules and automates routine managements tasks, such as:
- Database consistency checks
- Index rebuilds and defragmentations
- Backups (Full, Differential, and Transaction Log)
Advanced reporting capability
SQL Server Integration Services (SSIS)
Data warehousing
Performance and diagnostic tools available
- Index Optimization Advisor
- Profiler
- Performance/System Monitor
SQL Security
Standardized relational database (which most third-party applications and
reporting tools are compatible with)
SQL Server Fundamentals About SQL Server
Page 8 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
About SQL Server (continued)
1
Core Components of Microsoft SQL Server
Some of the core components of SQL Server include:
Database Engine: This is the core service in SQL Server that provides a way to
store, process, retrieve, and secure your data. With the services in the Database
Engine, you can build applications that allow for online transaction processing
(OLTP). It also supports online analytic processing (OLAP).
Analysis Services: This service provides OLAP and data mining capabilities to
the SQL Server databases. With these capabilities, you can make decisions
quickly without having to wait for someone to create a report.
Integration Services: This service integrates information from various data
sources. Also known as SQL Server Integration Services (SSIS), it provides a
platform to build data integration applications. The SSIS package features a fast
and flexible data extraction, transformation, and loading (ETL) engine.
Reporting Services: This service provides a way to capture data from your
database in a meaningful way without the need for writing queries or
understanding the underlying technologies of SQL Server.
- Delivers enterprise-wide reporting functionality.
- Queries a wide variety of data sources.
- Publishes reports in various formats.
- Supports pull- or push-driven delivery.
- Manages security on content and tasks centrally.
- Scales to support thousands of users.
- Enables extensions to core functionality.
Business Intelligence Development Studio: Business Intelligence Development
Studio is a fully integrated development environment (IDE) built on top of Visual
Studio 2008. It is used for creating SQL Server Business Intelligence solutions for
gathering, storing, analyzing, and providing access to data to help enterprise users
make better business decisions. Business Intelligence Development Studio
includes additional project types specific to SQL Server Business Intelligence.
Each project type supplies templates for creating the objects required for Business
Intelligence solutions and provides a variety of designers, tools, and wizards to
work with the objects. Business Intelligence is used for:
- Understanding the health of the organization.
- Collaborating on a shared view of business drivers.
- Reducing the time to decision.
Coming soon are the Master Data Services, Modelling Services, and
StreamInsight [used for developing and deploying complex event processing
(CEP) applications].
Certified Student Course Curriculum - Version 2.0 Page 9
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals About SQL Server
About SQL Server (continued)
1
SQL Server Books Online
The SQL Server Books Online is the primary documentation available with SQL
Server. It includes the following information:
Setup and upgrade instructions
Information about new features and backward compatibility
Conceptual descriptions of the technologies and features
Procedural "how to" topics
Tutorials that guide you through common tasks
Reference documentation for graphical tools, utilities, programming languages,
and APIs
Descriptions of the sample databases and applications included with SQL Server
Although you can select to install SQL Server Books Online during installation, you
can access it from the following location as well:
http://msdn.microsoft.com/en-us/library/ms130214.aspx
For information about other resources and references, see Resources and
References on page 251.
SQL Server Fundamentals Database Basics
Page 10 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Database Basics
1
This section covers some core database basics, such as tables, database objects, data
types, constraints, and indexes. This section also looks at the specifics of how data is
stored in the SQL Server databases.
Relational Database Concepts
Databases are a collection of information comprising of data tables and other objects,
such as views, stored procedures, etc. In a relational database, information is stored
within tables that "relate" to one another.
The software used to organize data in the relational model is known as relational
database management system (RDBMS).
Tables
Databases contain tables of information that are used to store data.
- Tables contain rows and columns used for storing data.
- Data is organized in a row and column format similar to a spreadsheet.
- Each row represents a unique record and each column represents a field within
a record.
- The rows in the table contain the actual data.
- Tables have indexes to improve performance. (Indexes also store data.)
- The primary key uniquely identifies a row in the table. A foreign key stores
the primary key from another table in the current table.
The following is a sample of the AP1_VendorMaster table. In this example, the
AP1_VendorMaster table has columns for Division, VendorNumber,
VendorName, and AddressLine1.
Data Types
Like many programming languages, SQL uses the concept of data types. Data types
are classifications of data, such as integers or characters.
Certified Student Course Curriculum - Version 2.0 Page 11
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Database Basics
Database Basics (continued)
1
Constraints
Constraint programming provides a way to state conditions or relationships in the
form of equations. Constraints are embedded within the host language or through the
use of libraries.
A primary key is considered to be a constraint. By default, primary keys are
physically implemented as unique, clustered indexes in SQL Server.
Indexes
Indexes help the retrieval of data from tables, particularly in the case of large amounts
of data.
The different types of relational indexes are clustered, non-clustered, and XML.
A clustered key is based on the columns defined for the clustered index.
- Data is ordered in the table according to the clustered key.
- Data within pages is stored in order and pages are logically linked in order.
- If a table does not have a clustered index it is known as a "heap."
- A table can only have one clustered index associated with it.
- Rows inserted have single logical target location when unique.
- The structure SQL Sever builds and uses for indexes is a balanced B-tree as
illustrated below.
SQL Server Fundamentals Database Basics
Page 12 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Database Basics (continued)
1
A B-tree is a structure for placing and locating records or keys in a database.
- Records are stored in locations called leaves, which are located the same
distance from the root.
- Additionally, the same number of leaves are located on the right and left sides
of the tree; thereby, providing "balance" to the tree.
- Records in a balanced tree can be located faster.
Non-clustered indexes do not have a particular order to them.
- A table can have many non-clustered indexes associated with it.
- Keep in mind - if a table has several indexes, a write is performed for each
index every time a row is added to the table.
- If there is not enough room for a new value in a leaf-level page, a page split is
performed where half of the rows are written to a new location.
- The following illustrates the structure for a non-clustered index.
Certified Student Course Curriculum - Version 2.0 Page 13
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Database Basics
Database Basics (continued)
1
Both clustered and non-clustered indexes can have a maximum of 16 columns and
900 bytes. For more information about the maximum sizes of objects for various
SQL Server components, refer to the Maximum Capacity Specifications for SQL
Server article on msdn at:
http://msdn.microsoft.com/en-us/library/ms143432.aspx
XML indexes:
- Can have up to 2 GB of data in a column.
- Have a structure that can be queried.
- The data structure must be scanned by SQL Server to find the data in the XML
document.
Over time, indexes can become fragmented because of re-writes, page splits, etc.
- It is a good idea to perform maintenance on your indexes on a regular basis.
- Monitor your index fragmentation to determine how often or when you need
to perform maintenance.
Database Objects
A database in SQL Server consists of a collection of objects such as tables, views,
stored procedures, and triggers that are defined to support the activities performed
with the data.
Stored Procedures
Stored procedures are modules of code written with the Transact-SQL programming
language that implement application logic or a business rule and are stored on the
SQL Server.
While stored procedures and triggers can be used to implement business rules, they
are not required. These objects allow for procedural code to execute in the SQL
Server process space. In fact, they are not recommended in the Sage ERP MAS 200
SQL product.
Views
Views define a set of data to be selected or modified from tables and are used to
simplify query commands, enhance programming consistency, provide data security,
and productivity for the databases.
Triggers
Triggers are commands that are executed automatically when an UPDATE, INSERT,
or DELETE statement is issued against a table or view. Each table can have one
INSERT trigger, one DELETE trigger, and one UPDATE trigger, but is not required
to have any triggers at all.
Note: Microsoft SQL Server 2008 allows for multiple triggers to be created for each
DML, DDL, or LOGON event.
SQL Server Fundamentals Database Basics
Page 14 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Database Basics (continued)
1
Understanding the SQL Server Databases
1
A database in Microsoft SQL Server consists of a collection of objects such as tables,
views, stored procedures, and triggers, that are defined to support the activities
performed with the data.
After your Sage ERP software is installed and set up, you can view and manage the
databases in Microsoft SQL Server Management Studio. Several databases are
created with the installation of SQL Server as described below.
The following shows the databases that reside in SQL Server prior to your Sage ERP
databases being created.
master: This database records all of the system-level information for a SQL
Server system. It records all login accounts and all system configuration settings.
This database records the existence of all other databases, including the location
of the database files and the initialization information for SQL Server; always
have a recent backup of the master database available. Never delete this database.
model: This database is used as the template for all databases created on a system.
When a CREATE DATABASE statement is issued, the first part of the database is
created by copying in the contents of the model database, and then the remainder
of the new database is filled with empty pages. Never delete this database.
msdb: This database is used by SQL Server Agent for scheduling alerts and jobs,
and recording operators. The msdb database also holds SQL Server Integration
Services (SSIS) packages. Never delete this database.
tempdb: This database holds temporary tables, temporary stored procedures,
temporary indexes, and other various temporary objects used by SQL Server
internal processes. It also fills any other temporary storage needs such as work
tables generated by SQL Server. It is a global resource; the temporary tables and
stored procedures for all users connected to the system are stored there. This
database is re-created every time SQL Server is started so the system starts with a
clean copy of the database. Because temporary tables and stored procedures are
dropped automatically on disconnect, and no connections are active when the
system is shut down, there is never anything in this database to be saved from one
session of SQL Server to another. Never delete this database.
Certified Student Course Curriculum - Version 2.0 Page 15
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Database Basics
Database Basics (continued)
1
The following illustration shows the initial tempdb configuration.
Files and Filegroups
Databases consist of filegroups and filegroups consist of collections of files. The
three types of filegroups include:
Data
Full text
FILESTREAM
The following are the different file extensions used for data files. These files help
with data placement and administrative tasks.
.mdf: Data file - this is the primary file that can be backed up and copied.
.ldf: Log file.
.ndf: Secondary file - usually located on read-only secondary filegroups.
These are considered the default file extensions and do not need to be used; however,
to avoid confusion, using these extensions is recommended. The main files in a
database are the .mdf and .ldf files. In SQL Server, data and log information are never
combined in the same file. Also, these files are only used by one database.
It is important that files be sized appropriately. Empty space is a good thing. The
autogrow option allows the database to automatically grow as additional transactions
are added to the database. This option can be accessed by right-clicking a database in
SQL Server Management Studio and selecting Properties. For more information,
see Viewing and Configuring Database Properties on page 86.
SQL Server Fundamentals Database Basics
Page 16 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Database Basics (continued)
1
What is an Instance?
In SQL Server, you can have more than one instance installed. An instance contains
its own settings and parameters for running SQL Server. Each instance also has its
own databases and files.
It is important to create instances for the following purposes:
Testing and quality assurance
To support different service packs
Note: It is recommended for production servers, to only have a single instance.
Troubleshooting performance problems become much more difficult in a multiple
instance situation.
Certified Student Course Curriculum - Version 2.0 Page 17
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Security
Security
1
By design, Microsoft SQL Server offers a very secure architecture. For more
information, download the white paper offered by Microsoft titled "Security
Overview for Database Administrators." This white paper covers some of the most
important security features in SQL Server 2008, including how to install SQL Server
securely and maintain a secure system.
http://www.microsoft.com/sqlserver/2008/en/us/wp-sql-2008-security.aspx
Authentication Modes
During the SQL Server installation, you need to define the authentication mode that
SQL Server uses to determine the types of logins that are allowed. The authentication
modes available are:
Windows authentication only: Can only use Windows accounts to log on to a
SQL Server instance.
Mixed Mode authentication: Allows for Windows and SQL Server
authentication to log on to the SQL Server instance.
- This authentication method has been improved in SQL Server 2008 to support
encryption of the channel by default through the use of SQL-generated
certificates.
Granting Permissions
As another layer of security, you can grant or deny permissions to users at the object
level (such as tables), database level, and the server level within SQL Server.
Additionally, within your Sage ERP product, you can grant or restrict access and
permissions to tasks within the software.
SQL Server Fundamentals Using the SQL Server Interface
Page 18 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Using the SQL Server Interface
1
SQL Server offers many tools for managing your services and databases. Although
SQL Server ships with several tools, not all of these tools are discussed in this
curriculum. For more information about all the tools available with SQL Server, be
sure to review the SQL Server Books Online documentation.
All of the tools mentioned in this section are discussed in greater detail throughout
this curriculum. This section is merely intended to get you familiar with some of the
tools available and the interfaces.
As you can see in the illustration below, the main areas you can access include
Configuration Tools, Performance Tools, Import and Export Data (32 bit), and the
SQL Server Management Studio. Other tools may also be available depending on
which services you select during the installation, such as Analysis Services and
Integration Services.
The Import and Export Data menu option launches the SQL Server Import and
Export Wizard, which allows you to create simple packages for importing and
exporting data between databases, spreadsheets, or text files. For more
information, see Overview of SQL Server Integration Services on page 207.
Certified Student Course Curriculum - Version 2.0 Page 19
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Using the SQL Server Interface
Using the SQL Server Interface (continued)
1
SQL Server Configuration Manager
You can use the SQL Server Configuration Manager to configure the SQL Server
services and network connectivity. This tool manages the services related to SQL
Server.
This window is accessed by selecting Start menu > All Programs > Microsoft
SQL Server 2008 > Configuration Tools > SQL Server Configuration Manager.
You can right-click a service to view its properties.
Select a node in the left pane
to view its associated services
or protocols in the right pane.
Right-click the state of a
service to start, stop, pause,
resume, or restart the service.
SQL Server Fundamentals Using the SQL Server Interface
Page 20 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Using the SQL Server Interface (continued)
1
SQL Server Management Studio
The SQL Server Management Studio provides an integrated interface for accessing,
configuring, and managing all aspects of the SQL Server. This is the main interface
you will use when working with SQL Server. You can also use this interface to create
Transact-SQL (TSQL) statements (queries). The information in the SQL Server
Management Studio should be monitored on a constant basis and can be a good place
to start looking when encountering problems with SQL Server.
Use the view menu to select panes to
display in the SQL Server
Management Studio window.
All the databases
you have in your
system display
under the
Databases node.
As you choose to view
more panes, they display
as illustrated here. You
can also click and drag a
pane to a new location or
pin it in place.
The SQL Server
Agent is
used for
scheduling jobs.
Certified Student Course Curriculum - Version 2.0 Page 21
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Using the SQL Server Interface
Using the SQL Server Interface (continued)
1
The SQL Server Management Studio window is accessed by selecting Start menu
> All Programs > Microsoft SQL Server 2008 > SQL Server Management Studio.
Microsoft SQL Server Management Studio is a user-interface management
console for managing all components of your databases. Through this tool, you
can perform the following:
- Database maintenance
- Add, change, and delete databases
- Back up and restore databases
- Manage security access to components within your databases
For more information about SQL Server Management Studio, refer to the
"Introducing SQL Server Management Studio" article on the MSDN website at:
http://msdn.microsoft.com/en-us/library/ms174173.aspx
Page 22 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Lesson 3
SQL Server Fundamentals
Planning a SQL Server Installation
31
Every successful installation begins with planning and preparation. Before purchasing
hardware, installing software, or setting implementation deadlines, you should fully
understand what is required for setting up SQL Server with your Sage ERP product.
The topics in this lesson include:
Hardware Considerations
Upgrade Considerations
Certified Student Course Curriculum - Version 2.0 Page 23
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Hardware Considerations
Hardware Considerations
1
This section provides suggestions for basic hardware configurations, memory, and
processors.
When planning your system, some questions to consider include:
How large will the database be?
How many users are there and what are their usage plans?
What is the current and anticipated transaction volume?
Are other third-party systems and customizations being implemented?
What is the physical topology, including desktops, networks, and locations?
How many databases will occupy the SQL Server?
Is the server dedicated to SQL Server?
How many SQL Server instances are required?
Note: Implementing a Sage ERP system does not end after the installation. It requires
the database administrator to analyze and monitor the databases for optimal
performance.
SQL Server Fundamentals Hardware Considerations
Page 24 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Hard Drive Configuration (continued)
1
Basic Hardware Configuration
The following information can be used as an approximate guide when determining
the basic hardware configuration to use for your Sage product that uses SQL Server.
Be sure to view the supported platform information located on the Sage Customer
Support website at www.sagesoftwareonline.com
Processors
If both the Application Server and Database Server are on the same machine, consider
using the current AMD or Intel x64 quad core processor. Use of processors that only
support x32 should be avoided. Itanium processors are not supported. Be sure to view
you Sage ERP products requirements on the Sage Customer Support website.
Memory
By default, Microsoft SQL Server uses all the memory that is available.
When using SQL Server Standard edition, it is recommended having enough
memory to achieve 95% to 99% cache hit ratio and up to the operating system
maximum for the SQL Server Enterprise edition.
When purchasing a server, make sure there are available memory slots for
expansion.
SQL Server can put the databases used into memory for faster accessing of the
data.
The Application Server requires more memory than the SQL Server.
- As an example, in a 20-user system that has a server with 8 GB of memory,
you could allocate 3 GB to SQL Server and 5 GB to the operating system and
Application Server.
- As always, keep in mind, there are many factors to consider when allocating
memory to different components of your system.
Certified Student Course Curriculum - Version 2.0 Page 25
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Hardware Considerations
Hard Drive Configuration (continued)
1
Network Cards
Multiple network cards are recommended to prevent bottlenecks on the network,
especially with a large number of clients and concurrent users.
Other important network elements are speed of the network, latency to the client,
and performance characteristics of the network card.
Be aware that having multiple network cards can increase network configuration
complexity and network management.
Hard Drive Configuration
You may consider using a RAID disk array configuration, especially if you have an
enterprise-level business. RAID stands for Redundant Array of Independent Disks
and is a disk system that contains multiple disk drives, called an array to help
maintain data protection and access. When choosing a RAID level that is right for
your business, you must balance and consider many factors, including the number of
users on your system, cost of disk storage, the data availability required, and
performance requirements.
For more information about RAID, refer to the following articles on the MSDN
website:
RAID -
http://msdn.microsoft.com/en-us/library/ms184252.aspx
RAID Levels and SQL Server -
http://msdn.microsoft.com/en-us/library/ms190764.aspx
Comparing Different Implementations of RAID Levels -
http://msdn.microsoft.com/en-us/library/ms178048.aspx
Large scale Considerations
Work with the manufacturer for optimal configuration.
SQL Server Fundamentals Hardware Considerations
Page 26 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Hard Drive Configuration (continued)
1
Test Server
During the implementation or future upgrades, it is important to plan on having a test
server available. A test server allows you to apply Product Updates, service packs,
enhancements, and test future releases without affecting a production database.
It is not recommended that you use the production server as the test server.
It is important to budget this additional requirement during the hardware planning
phase of the implementation or sales cycle.
SQL Server instancing can be used for testing, but applying SQL Server updates
and managing performance impact are difficult.
Using virtualization can help reduce the complexity of managing SQL Server
updates to test systems. Tighter controls can be placed on the test SQL Server to
reduce its impact on the production server.
It is recommended that the test SQL Server be a separate physical server from the
production server.
Certified Student Course Curriculum - Version 2.0 Page 27
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Upgrade Considerations
Upgrade Considerations
1
Before Upgrading from SQL Server 2000/2005
Some things to remember if you are upgrading from SQL Server 2000/2005:
Review the "Whats New" features.
Document all existing systems.
Develop validation tests.
Develop performance benchmarks.
Capture baseline data for these.
Formulate and test a rollback plan.
Identify the upgrade stakeholders: application, database, hardware, infrastructure,
users, business sponsor.
Some known pain points when upgrading from SQL Server 2000 are:
Notification Services
Data Transformation Services (DTS): Clients often have large investments in
DTS packages. You could consider rewriting the packages using a third-party tool
such as DTSXChange.
Some know pain points when upgrading from SQL Server 2005 are:
Anonymous access to Report Manager.
Start with a Clean Environment
When upgrading from a prior version of SQL Server, you should try to start with a
clean environment. This includes performing the following:
Check the database for consistency.
Shrink databases that need to be copied.
Ensure full backups are available.
Make sure to communicate internally:
- Avoid colliding with other activities.
- Disable auto-restarts of servers, automatic maintenance, etc.
- Ensure all staff is aware and that everyone has access to emergency contacts.
SQL Server Fundamentals Upgrade Considerations
Page 28 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Upgrade Considerations (continued)
1
After the Upgrade
You should perform the following after upgrading:
Review all logs.
Update statistics if needed (likely if upgrading from SQL Server 2000).
Reconfigure and re-establish high availability and disaster recovery solutions.
Verify agent jobs work as expected.
Ensure security still works as expected. Verify the following:
- No user accounts received elevated security.
- All logins for SQL Server were transferred.
- All database users got reassigned to logins.
Check for database consistency.
Certified Student Course Curriculum - Version 2.0 Page 29
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Challenge Questions - Part I
Challenge Questions - Part I
1
1. List at least three things you should do before upgrading from SQL Server
2000/2005.
________________________________________________________
________________________________________________________
________________________________________________________
Page 30 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Lesson 4
SQL Server Fundamentals
Installing and Registering Microsoft SQL Server
41
After careful planning, you are ready to install SQL Server to use with your Sage ERP
product. This lesson will also teach you how to add and register your server.
The topics in this lesson include:
Installing Microsoft SQL Server
Adding and Registering a New SQL Server
Adding a New SQL Server Group
Logging Onto SQL Server
Certified Student Course Curriculum - Version 2.0 Page 31
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Installing Microsoft SQL Server
Installing Microsoft SQL Server
1
After carefully selecting and preparing the appropriate configurations for your server
based on the needs of your client and Sage ERP, you are ready to take the first step of
the installation process by installing Microsoft SQL Server.
Note: Some Sage ERP products offer an OEM version of SQL Server, such as Sage
ERP MAS 200 SQL, which gives you another option for installing SQL Server with
the parameters pre-defined for you.
Refer to the following article on the MSDN website titled Installing SQL
Server 2008:
http://msdn.microsoft.com/en-us/library/bb500395.aspx
Before You Begin
After launching the SQL Server installation .exe file, the following screen appears
with helpful links to documentation in addition to a System Configuration Checker
tool.
If you are upgrading from SQL Server 2000 or 2005, be sure to run the Install
Upgrade Advisor to identify and fix any issues before proceeding with the
installation.
The System Configuration Checker allows you to check for any conditions that
may prevent a successful installation.
SQL Server Fundamentals Installing Microsoft SQL Server
Page 32 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Installing Microsoft SQL Server (continued)
1
Sets for Installing Microsoft SQL Server:
1. Log onto the database server using a Windows account that is a member of the
Local Adminstrators group (not the domain administrator).
2. Insert the SQL Server DVD into the DVD drive or access the .exe file provided by
your instructor. The SQL Server Installation Center screen displays.
3. Select the Installation option. The following screen displays.
There are several installation options to choose from:
New SQL Server stand-alone installation or add features to existing
installation: This installation option allows you to install SQL Server in a non-
clustered environment or add features to an existing SQL Server instance.
New SQL Server failover cluster installation: This option allows you to install
a single-node SQL Server failover cluster.
- With failover clustering implemented, another server can take over in the case
of a hardware failure.
- SQL Server failover clusters are built on top of Windows clusters.
- In this case, the single-node cluster has one instance of SQL Server installed.
Add node to a SQL Server failover cluster: This option allows you to add a
node to an existing failover cluster.
Certified Student Course Curriculum - Version 2.0 Page 33
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Installing Microsoft SQL Server
Installing Microsoft SQL Server (continued)
1
Upgrade from SQL Server 2000 or SQL Server 2005: This option allows you
to upgrade from SQL Server 2000 or 2005 to SQL Server 2008.
Search for product updates: This option allows you to search for product
updates for SQL Server 2008.
4. For our example, we will select the "New SQL Server stand-alone installation or
add features to existing installation" option. The Setup Support Rules screen
displays.
The Setup Support Rules screen identifies any problems that might occur. Failures
must be corrected before proceeding with the installation.
SQL Server Fundamentals Installing Microsoft SQL Server
Page 34 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Installing Microsoft SQL Server (continued)
1
5. Click OK.
The components that are required to install or update SQL Server 2008 display in
the Setup Support Files screen.
Certified Student Course Curriculum - Version 2.0 Page 35
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Installing Microsoft SQL Server
Installing Microsoft SQL Server (continued)
1
6. Click Install to install the Setup Support files.
Rules display along with the status of Passed, Failed, Warning, or Not applicable.
You must fix any items that fail the configuration before proceeding with the
installation.
Click this link to
read more details
about the warning.
SQL Server Fundamentals Installing Microsoft SQL Server
Page 36 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Installing Microsoft SQL Server (continued)
1
7. Click Next.
Specify whether to perform a new installation or add features to an existing
instance of SQL Server.
Certified Student Course Curriculum - Version 2.0 Page 37
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Installing Microsoft SQL Server
Installing Microsoft SQL Server (continued)
1
8. Click Next.
SQL Server Fundamentals Installing Microsoft SQL Server
Page 38 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Installing Microsoft SQL Server (continued)
1
9. Enter your product key and click Next.
10. Select the I accept the license terms check box and click Next.
Certified Student Course Curriculum - Version 2.0 Page 39
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Installing Microsoft SQL Server
Installing Microsoft SQL Server (continued)
1
11. The Setup Role screen displays.
Select whether to individually select which feature components to install or to
install all features using default values for the service accounts.
12. In our example, we will select to install all features with defaults.
13. Click Next.
SQL Server Fundamentals Installing Microsoft SQL Server
Page 40 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Installing Microsoft SQL Server (continued)
1
14. The Feature Selection screen displays.
The best practice when working in a production environment is to only install the
services you absolutely need. Doing so reduces the surface area of your system,
which in turn, reduces risk from outside attacks.
If this is the second installation of SQL Server, shared services will already be
selected.
15. In our example, we will select the Database Engine Services check box.
Certified Student Course Curriculum - Version 2.0 Page 41
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Installing Microsoft SQL Server
Installing Microsoft SQL Server (continued)
1
16. Click Next. The Installation Rules window displays.
Installation rules are run to determine if the installation process should be
stopped.
17. If needed, click Show details to view more information about failed items.
18. Click Next.
SQL Server Fundamentals Installing Microsoft SQL Server
Page 42 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Installing Microsoft SQL Server (continued)
1
19. Click Next. The Instance Configuration screen displays.
If this is the first installation of SQL Server on your system, the Default instance
option is selected and the default "MSSQLSERVER" name displays.
The Instance Configuration screen allows you to use the default installation or
create a named instance of SQL Server.
Multiple instances of SQL Server can be configured and used on a single server
by Sage ERP. Each occurrence must use unique ports.
- Instances can be different SQL Server versions, or the same version with
different service packs.
Certified Student Course Curriculum - Version 2.0 Page 43
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Installing Microsoft SQL Server
Installing Microsoft SQL Server (continued)
1
20. Select the Default instance option and click Next. The Disk Space Requirements
screen displays.
Review the disk usage summary based on the SQL Server features you previously
selected.
SQL Server Fundamentals Installing Microsoft SQL Server
Page 44 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Installing Microsoft SQL Server (continued)
1
21. Click Next. The Server Configuration screen displays.
Microsoft recommends entering a separate account and password for the SQL
Server service.
If you click the "Use the same account for all SQL Server services" button the
following window displays.
- Enter the account name and password to use for all the services
Certified Student Course Curriculum - Version 2.0 Page 45
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Installing Microsoft SQL Server
Installing Microsoft SQL Server (continued)
1
22. At the Startup Type field for the SQL Server Agent service, select Automatic.
23. Click Next.
Use the Collation tab to view the collation sequence set for the Database Engine
and Analysis Services.
Depending on your language support needs, make the needed adjustments.
Check your business application requirements.
It is important to note that once the collation method is set, it can be very difficult
to change.
Not all products use the same collation setting. Be sure to check the requirements
for your specific Sage ERP product.
SQL Server Fundamentals Installing Microsoft SQL Server
Page 46 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Installing Microsoft SQL Server (continued)
1
24. Click Next. The Database Engine Configuration screen displays.
Select the authentication mode to use for SQL Server.
- Be sure to check the requirements for your specific Sage ERP product when
selecting the authentication mode.
- The password that you enter will be assigned to the SQL Server login "sa" (for
system administrator).
- Always use a strong password for the sa login.
Use the Add Current User button to add the Windows account you are running the
installation in as an administrator in SQL Server.
You can also determine who the SQL Server administrators will be in the Specify
SQL Server Administrators section.
25. Select the needed authentication mode and create a system administrator
password.
26. Click Add Current User to add yourself as the administrator in SQL Server.
Certified Student Course Curriculum - Version 2.0 Page 47
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Installing Microsoft SQL Server
Installing Microsoft SQL Server (continued)
1
27. Click the Data Directories tab.
Use the Data Directories tab to review or change the directories for the data root,
database, database log, tempdb, tempdb log and backup.
Best practice is to
place the backup
directory on a
different drive.
SQL Server Fundamentals Installing Microsoft SQL Server
Page 48 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Installing Microsoft SQL Server (continued)
1
28. Keep the default directory locations and click the FILESTREAM tab.
Use the FILESTREAM tab to enable FILESTREAM for this installation of SQL
Server 2008.
- FILESTREAM combines SQL Server Database Engine with the NTFS file
system allowing you to store unstructured data, such as text documents and
images on the file system.
- Transact-SQL statements (also known as T-SQL statements) can be used to
insert, update, query, search, and back up the FILESTREAM data.
Certified Student Course Curriculum - Version 2.0 Page 49
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Installing Microsoft SQL Server
Installing Microsoft SQL Server (continued)
1
29. Click Next. The Error and Usage Reporting screen displays.
You can specify whether to send error reports or usage reports to Microsoft.
SQL Server Fundamentals Installing Microsoft SQL Server
Page 50 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Installing Microsoft SQL Server (continued)
1
30. Click Next. The Installation Rules screen displays.
The Installation Rules screen is used to determine if the installation process will
be blocked for any reason.
Certified Student Course Curriculum - Version 2.0 Page 51
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Installing Microsoft SQL Server
Installing Microsoft SQL Server (continued)
1
31. Click Next. The Ready to Install screen displays.
The Ready to Install screen allows you to view the installation selections you have
made prior to installing.
SQL Server Fundamentals Installing Microsoft SQL Server
Page 52 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Installing Microsoft SQL Server (continued)
1
32. Review the selected features and click Install. The Installation Progress screen
displays.
The installation routines for the various features you selected display along with
the status of Success or Failure.
Certified Student Course Curriculum - Version 2.0 Page 53
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Installing Microsoft SQL Server
Installing Microsoft SQL Server (continued)
1
33. Click Next. The Complete screen displays.
If your installation has installed successfully, a message displays.
34. Click Close. The SQL Server Installation Center screen displays. Close the SQL
Server Installation Center screen.
35. After installation has completed, install the necessary service packs that are
compatible with your system. Be sure to refer to your Sage ERP products
Compatibility and Resource Guide for the most recent compatible and supported
SQL Server service packs.
36. Apply any needed service packs and restart your system.
Note: Service packs must be installed to each instance separately.
37. Register your SQL Server. For more information, see Adding and Registering a
New SQL Server on page 56.
38. Start your SQL Server through SQL Server Management Studio by right-clicking
your server name and choosing Start or Stop.
You can see the status of the server by looking at the server icon.
If there is a green arrow next to the server name, SQL is current running.
If there is a red square, SQL Server is currently stopped.
SQL Server Fundamentals Installing Microsoft SQL Server
Page 54 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Installing Microsoft SQL Server (continued)
1
Additional Options in the SQL Server Installation Center
There are many other tools and resource available in the SQL Server Installation
Center including the following options:
Maintenance: Use this option to change the edition of SQL Server 2008, repair a
corrupt installation, or remove a node from an existing failover cluster.
Tools: Use this option to check for conditions that may prevent a successful
installation, view a report of all SQL Server products and features installed on the
local server, and upgrade to the current Integration Services package format.
Resources: Use this option to access a wide variety of resources about SQL
Server. You can also use the Codeplex samples website link to download and
install the AdventureWorks sample databases.
Advanced: Use this option to use an existing configuration file in order to install
SQL Server, prepare SQL Server for failover cluster installation, and complete a
failover cluster from a list of cluster-prepared SQL Server instances.
Options: Use this option to specify the architecture of SQL Server to install and
specify the location of the installation media.
Certified Student Course Curriculum - Version 2.0 Page 55
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Installing Microsoft SQL Server
Installing Microsoft SQL Server (continued)
1
Activity
Use the following activity to install a second instance of Microsoft SQL Server on
your system.
1. Install the Microsoft SQL Server software. Open the Student folder on your
desktop and select Enterprise, and then the Setup icon (green with white arrow).
2. In the SQL Server Installation Center screen, select the Installation option on the
left side of the screen, and then select the New SQL Server stand-alone
installation or add features to an existing installation option.
3. In the Setup Support Rules screen, click OK.
4. Click Install to install the Setup Support files, and then click Next.
5. Select the Enter the product key option and accept the product key provided by
default. Click Next.
6. Select the SQL Server Feature Installation option and click Next.
7. Select the I accept the license terms check box and click Next.
8. Select the SQL Server Feature Installation option and click Next.
9. Select the Database Engine Services check box and click Next. Notice that the
shared services from the first installation are already selected.
10. Select the Named Instance option and enter . Click Next.
11. In the Disk Space Requirements screen, click Next.
12. At the Account Name drop-down, browse for the local administrators account.
At the password field, enter .
13. In the Server Configuration screen, select Automatic at the Startup Type field for
the SQL Server Agent service. Click Next.
14. Click the Collation tab and ensure SQL_Latin1_General_CP1_C1_AS is selected.
Click Next.
15. Select the Mixed Mode option and enter as the system
administrator (sa) password.
16. Click Add Current User to add yourself as the administrator.
17. Keep the default directories and settings for the Data Directory and
FILESTREAM tabs. Click Next.
18. In the Error and Usage Reporting screen, click Next.
19. In the Installation Rules screen, correct any failed items and click Next.
20. In the Ready to Install screen, review the installation features you are installing
and click Install.
21. In the Complete screen, click Close.
22. Close the SQL Server Installation Center screen.
SQL Server Fundamentals Adding and Registering a New SQL Server
Page 56 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Adding and Registering a New SQL Server
1
You must register your server in SQL Server Management Studio. In SQL Server
Management Studio, you are able to attach and manage other SQL Servers or
instances through SQL Server groups. This allows you to perform SQL functions
without having to go physically to the server.
To add and register a new server, right-click the server or server group, select New,
and then Server Registration. The New Server Registration dialog box appears.
Steps for Adding and Registering a SQL Server:
1. From the Start menu, select Programs > Microsoft SQL Server 2008 R2 > SQL
Server Management Studio.
Note: If this is the first time you are accessing SQL Server Management Studio,
you may receive a message stating that you can import customized user setting
from a previous version of SQL Studio.
2. If prompted to log into SQL Server, select the SQL Server Authentication method
and enter your login and password.
3. Click Connect.
4. In SQL Server Management Studio, make sure the Object Explorer is in view
(select View menu > Object Explorer).
5. Right-click the server name and select Register.
Certified Student Course Curriculum - Version 2.0 Page 57
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Adding and Registering a New SQL Server
Adding and Registering a New SQL Server (continued)
1
6. On the General tab, enter the server name you are registering or select the server
name from the drop-down. You can enter the following for the server name:
Server's IP address
127.0.0.1 (local loopback IP address)
The server's name
Use a period (.) for local server or type (local)
7. Select the authentication mode to connect to that server at the Authentication
field.
SQL Server implements two ways to control access to SQL Server data:
- Windows authentication, implementing trusted connections
- SQL Server authentication
Note: SQL Server security is discussed in another lesson.
8. Click the Connection Properties tab and select the database to connect to from the
Connect to database field.
9. Select a network protocol and network packet size.
Note: The available protocols are configured using the Client Network
Configuration.
SQL Server Fundamentals Adding and Registering a New SQL Server
Page 58 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Adding and Registering a New SQL Server (continued)
1
10. Enter the amount in time in seconds before a connection or task times out.
11. Click Test to test the connection to the server selected at the Server name field and
click Save.
12. In SQL Server Management Studio, select the View menu > Registered Servers.
The Registered Servers panel appears on the left side of the SQL Server
Management Studio window.
13. Expand the Database Engine node and then the Local Server Groups node. You
can see the server that you registered.
Certified Student Course Curriculum - Version 2.0 Page 59
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Adding and Registering a New SQL Server
Adding and Registering a New SQL Server (continued)
Activity
Use the following activity to add and register the Sage_SQL server that you installed
in the previous lesson.
1
1. If you are not in SQL Server Management Studio, access it now and log into SQL
Server if prompted. Select Start menu > All Programs > Microsoft SQL Server
2008 R2 > SQL Server Management Studio.
2. At the Connect to Server window, enter the following:
Server name:
Select the SQL Server authentication option.
Login:
Password:
3. Click Connect.
4. From SQL Server Management Studio, in the Object Explorer, right-click the
Sage_SQL server and select Register.
Note: If you are editing the registration of an existing server, right-click the server
and select Properties.
5. The New Server Registration window displays.
6. On the General tab, at the Server name field, select the Sage_SQL server name.
7. Make sure the authentication method is set to SQL Server Authentication with the
following login information:
Login:
Password:
8. At the Registered server name field, keep the server name as Sage_SQL.
9. Click the Connection Properties tab.
10. Keep the default connection database, network protocol, and network packet size.
11. Enter for the amount of time in seconds before a connection or task times out.
12. Click Test to test the connection and click Save.
13. To view your registered server, from SQL Server Management Studio, select the
View menu > Registered Servers. The Registered Servers panel displays on the
left side of the SQL Server Management Studio window.
14. Expand the Database Engine folder.
SQL Server Fundamentals Adding a New SQL Server Group
Page 60 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Adding a New SQL Server Group
1
You can create a server group in SQL Server Management Studio and place your
server within the server group. Server groups provide a convenient way to organize a
large number of servers into a few manageable groups.
For example, you can create a server group for your client's databases and have a
separate group for your own internal databases.
Steps for Adding a New SQL Server Group:
1. In SQL Server Management Studio, select the View menu > Registered Servers.
The Registered Servers pane appears on the left side of the SQL Server
Management Studio window.
2. Expand the Database Engine node. Right-click a server or server group and select
New Server Group. The New Server Group Properties window displays.
You can use New Server Group Properties to create new server groups or organize
large numbers of registered servers.
3. Enter the group name, description, and then select the location of the group.
Note: You can add the group as a sub-group of another group.
4. Click OK. You can now add SQL Server installs to the new group. You can also
move servers from another location to your new group by right-clicking the server
you are moving and selecting Tasks > Move to.
Enter the name of
your new server
group here.
Certified Student Course Curriculum - Version 2.0 Page 61
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Adding a New SQL Server Group
Adding a New SQL Server Group (continued)
1
Activity
Use the following activity to create a new server group and then move the server you
registered in a previous activity into the new group.
1. If you are not currently in SQL Server Management Studio, access it now by
selecting Start menu > All Programs > Microsoft SQL Server 2008 R2 > SQL
Server Management Studio.
2. Log into SQL Server if prompted.
3. Select View menu > Registered Servers.
4. Expand the Database Engine node.
5. Expand the Local Server Groups node.
6. Right-click the Local Server Groups node and select New Server Group.
7. Provide a group name, such as and click OK.
8. Next, right-click the server you registered in the previous activity and select Tasks
> Move to.
9. Expand the Local Server Group node and select Web Group.
10. Click OK. Your server is now located in the Web Group folder.
Select a node on the
server tree to specify
the location
you are moving the
server to.
SQL Server Fundamentals Logging Onto SQL Server
Page 62 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Logging Onto SQL Server
1
Steps for Logging Onto SQL Server
1. From the Start menu, select All Programs > Microsoft SQL Server 2008 > SQL
Server Management Studio.
2. Select your server name and select the authentication mode.
3. Enter your system administrator login and password.
4. Click Connect.
5. In the SQL Server Management Studio window, make sure the Object Explorer
pane is in view (View menu > Object Explorer).
6. Expand the Databases node and then expand the System Databases node.
Note the standard system databases: master, model, msdb, and tempdb are
installed when the SQL Server is installed. For more information about these
databases, see Database Basics on page 10.
Certified Student Course Curriculum - Version 2.0 Page 63
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Logging Onto SQL Server
Logging Onto SQL Server (continued)
1
Activity
Use the following activity to log onto SQL Server.
1. From the Start menu, select All Programs > Microsoft SQL Server 2008 R2 > SQL
Server Management Studio.
2. At the Server Name field, select the Sage_SQL server name.
3. At the Authentication field, select SQL Server Authentication.
4. Enter for your system administrator login and then enter .
5. Click Connect.
6. In the SQL Server Management Studio window, make sure the Object Explorer
pane is in view (View menu > Object Explorer).
7. Expand the Databases node and then expand the System Databases node.
SQL Server Fundamentals Lab Exercise - Installing and Registering Microsoft SQL Server
Page 64 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Lab Exercise - Installing and Registering Microsoft SQL
Server
1. Install the Microsoft SQL Server software using the location of the SQL Server
Setup.exe file provided by your instructor. (page 31)
2. Select to install using the "New installation or add features to an existing
installation" option.
3. Enter the product key provided by your instructor. (page 38)
4. Install the following services: (page 40)
Database Engine Services
Business Intelligence Development Studio
Integration Services
Management Tools
5. Select to install using a named instance. If you used "Sage_SQL" during the
previous activity, enter anther name, such as Sage_[your initials]. (page 42)
6. Set the SQL Server Agent service to start up automatically. Also, use the same
account for all SQL Services. (page 44)
7. Ensure SQL_Latin1_General_CP1_C1_AS is selected as a collation. (page 45)
8. Use Mixed Mode authentication and enter a password for the system
administrator (sa) logon. (page 46)
9. Add yourself as the administrator. (page 46)
10. Keep the default directories and settings for the Data Directory and
FILESTREAM tabs. (page 47)
11. Correct any failed items before proceeding with the installation.
12. Add and register the SQL Server. Log onto SQL Server if prompted. (page 56)
13. Add the SQL Server instance to a new server group. (page 60)
Certified Student Course Curriculum - Version 2.0 Page 65
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Challenge Questions - Part II
Challenge Questions - Part II
1
1. Which utility should you run before installing SQL Server 2008 if you are
upgrading from SQL Server 2000/2005?
_______________________________________________________
_______________________________________________________
_______________________________________________________
2. Explain briefly how to add a new server group in SQL Server Management
Studio.
________________________________________________________
________________________________________________________
________________________________________________________
1
Page 66 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Lesson 5
SQL Server Fundamentals
Configuring SQL Server
51
After installing SQL Server you can use the SQL Server Properties window to ensure
the server is properly configured. This lesson will also teach you how to configure the
SQL Server properties.
The topics in this lesson include:
Configuring SQL Server Properties
Certified Student Course Curriculum - Version 2.0 Page 67
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Configuring SQL Server Properties
Configuring SQL Server Properties
1
After the SQL Server programs are installed, and your server has been registered, you
can configure the SQL properties for the server. There are several important
configuration options to review.
SQL Server Surface Area Configuration
The SQL Server Surface Area Configuration tool provides management and security
over the surface area of local and remote instances on the SQL Server. You can also
use this tool to disable unused services and network protocols for remote connections
and disable unused features of SQL Server components if needed. Disabling unused
features helps protect your server by reducing the surface area.
Steps for Managing the Server Surface Area
1. Right-click the server or instance name you would like to configure in SQL
Server Management Studio.
2. Select Facets as shown below.
SQL Server Fundamentals Configuring SQL Server Properties
Page 68 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Configuring SQL Server Properties (continued)
1
3. The View Facets window displays.
Only the facets that apply to the selected object type are displayed.
- According to SQL Server Online Books, a facet is a set of logical properties
that model the behavior or characteristics for certain types of managed targets.
The number and characteristics of the properties are built into the facet and
can be added or removed by only the maker of the facet. For more information
about facets, refer to SQL Server Online Books.
This feature also allows you to create a policy and condition for the selected facet
using the current state.
4. At the Facet drop-down field, select Surface Area Configuration. Make sure that
only the features required are enabled.
Select the facet
to display its
properties.
You can create a policy
using this button.
Properties that are bold
can be updated.
Properties that are
greyed out are read only.
Certified Student Course Curriculum - Version 2.0 Page 69
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Configuring SQL Server Properties
Configuring SQL Server Properties (continued)
1
Activity
Use the following activity to configure the surface area for the Sage_SQL server.
1
1. If you are not currently in SQL Server Management Studio, access it now and log
onto SQL Server if prompted. Select Start menu > All Programs > Microsoft SQL
Server 2008 R2 > SQL Server Management Studio.
2. In the SQL Server Management Studio window, access the Object Explorer by
selecting View menu > Object Explorer.
3. In SQL Server Management Studio, right-click the Sage_SQL server name and
select Facets. The View Facets window displays.
4. At the Facet drop down, select Surface Area Configuration.
5. Review the facet properties to ensure all unnecessary properties are disabled.
6. Click OK and close the View Facets window.
Server Properties
In SQL Server Management Studio, you can access and configure the properties of
the SQL Server. The Server Properties window allows you to:
Configure how much memory to use.
Determine how SQL Server works with processors on the server.
Set the authentication mode.
Set connection options.
View and grant permissions.
You can access the Server Properties window from SQL Server Management Studio
by right-clicking the server name and selecting Properties.
SQL Server Fundamentals Configuring SQL Server Properties
Page 70 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Configuring SQL Server Properties (continued)
1
Steps for Viewing and Configuring the SQL Server Properties
Use the following steps to view or set properties for the SQL Server, configure how
much memory to use, determine how SQL Server works with processors on the
server, set the authentication mode, set connection options, and view and grant
permissions.
1. In SQL Server Management Studio, right-click your server, and then select
Properties. The Server Properties window displays.
On the General page, you can view where SQL Server is running, what version,
how many processors, and how much memory the server has installed.
Certified Student Course Curriculum - Version 2.0 Page 71
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Configuring SQL Server Properties
Configuring SQL Server Properties (continued)
1
2. Select Memory under the Select a page section.
The Memory page is where you configure how much memory SQL Server is
allowed to use.
You can also configure how much memory is used for index creation and queries.
It is important that you do not allow SQL Server to use all the memory available
because the server needs memory for the operating system and other services
running.
If the amount of memory used is smaller than the physical amount of memory, do
not select the "Use AWE to allocate memory" check box. If the amount of
memory used is more than the physical amount of memory or if you notice
memory pressure on the server, consider selecting this check box and setting the
maximum SQL Server memory.
- AWE stands for Address Window Extensions, which allows a 32-bit process
to map memory outside of the Virtual Address Space.
- Using AWE can also be beneficial to performance in 64-bit systems. This is
possible if the SQL Server service account has the Lock Page in Memory
advanced user right.
SQL Server Fundamentals Configuring SQL Server Properties
Page 72 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Configuring SQL Server Properties (continued)
1
3. Select Processor under the Select a page section.
The Processors page allows you to choose how SQL Server works with the
processors on the server.
If using multiple processors, you can allocate one or more for SQL Server only.
You can use the Boost SQL Server priority check box to determine if SQL Server
should run at a higher priority than other processes on the same machine.
Do not enter a value in the "Maximum worker threads" field.
Certified Student Course Curriculum - Version 2.0 Page 73
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Configuring SQL Server Properties
Configuring SQL Server Properties (continued)
1
4. Select Security under the Select a page section.
On the Security page, you can select whether the SQL Server and Windows
Authentication mode option is used or if only Windows authentication is used.
Although Microsoft recommends using Windows Authentication, the
recommended authentication mode may differ depending on the specific Sage
ERP product you are running. Be sure to check with your Sage ERP product
documentation.
SQL Server Fundamentals Configuring SQL Server Properties
Page 74 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Configuring SQL Server Properties (continued)
1
5. Select Connections under the Select a page section.
Use the Connections page to specify default connection options, including
whether to allow remote connections to the server.
Default connections
control the behavior
of each SQL Server
process SPID as it
relates to transaction
behavior, ANSI
settings, remote
connections, etc.
Certified Student Course Curriculum - Version 2.0 Page 75
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Configuring SQL Server Properties
Configuring SQL Server Properties (continued)
1
6. Select Database Settings under the Select a page section.
The Default index fill factor is used for fine-tuning index data storage and
performance.
- For example, if you create or rebuild an index, the value at the Default index
fill factor field is used to determine the percentage of space on every leaf-level
page to be filled with data. The remainder of each page is reserved as free
space for potential growth.
- The fill factor can range from 1 to 100 representing percentage values.
- If this field is set to zero ( 0 ), the leaf-level pages are filled to capacity, which
is the server-side default.
Under the Database default locations section, you can determine the system
default file locations for new databases.
- This is important to set when your Microsoft SQL Server programs are on one
drive and your data and log files are installed on different drives.
SQL Server Fundamentals Configuring SQL Server Properties
Page 76 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Configuring SQL Server Properties (continued)
1
7. Select Advanced under the Select a page section.
You can use the Advanced page to make settings such as the cursor threshold. If
the query optimizer determines the number of returned rows is greater than the
cursor threshold, the cursor is generated asynchronously. If not, the cursor is
generated synchronously resulting in waiting until all rows are returned.
Under the Parallelism section, select how to allocate processor use with SQL
Server.
- Should have at least four processors for this to be effective.
- This may increase performance for the entire system while a large process is
running; however, that process may experience performance degradation.
Certified Student Course Curriculum - Version 2.0 Page 77
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Configuring SQL Server Properties
Configuring SQL Server Properties (continued)
1
8. Select Permissions under the Select a page section.
Use the Permissions page to view or grant permissions, such as altering logins,
altering any database, or altering connections.
The permissions available for objects may vary - not all options are available for
all explicit permissions.
9. Click OK to exit, and then restart your SQL Server.
Note: After making any changes to the SQL Server configuration, go back into the
properties to verify the changes were saved. If the changes were not saved, you may
need to log in as the user with enough security to apply the needed changes.
The permissions
you grant in the
lower grid pertain
only to the selected
object from the
upper grid.
SQL Server Fundamentals Configuring SQL Server Properties
Page 78 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Configuring SQL Server Properties (continued)
1
Activity
1. If you are not currently in SQL Server Management Studio, access it now and log
into SQL Server if prompted. (Select Start menu > All Programs > Microsoft SQL
Server 2008 R2 > SQL Server Management Studio.)
2. Right-click the Sage_SQL server name in Object Explorer (View menu > Object
Explorer) and select Properties.
3. Take a minute to review the information on the General page.
Where is the SQL Server running from? _____________________________
How many processors are on the server? ____________________________
Is failover clustering implemented? _________________________________
4. Select Memory under the Select a page section.
What is the maximum server memory in MB? _________________________
5. Select Processors under the Select a page section.
6. Select the Boost SQL Server Priority check box.
7. Do not make an entry at the Maximum worker threads field.
8. Select Security under the Select a page section.
9. Make sure the SQL Server and Windows Authentication mode option is selected.
10. Select Connections under the Select a page section.
11. Make sure the Allow remote connections to this server check box is selected.
12. Select Database Settings under the Select a page section.
13. Review the settings and keep all the defaults.
14. Select Advanced under the Select a page section.
What is the network packet size? __________________________________
15. Select Permissions under the Select a page section.
16. Review the settings and keep all the defaults.
17. Click OK to save any changes.
18. Close the Server Properties window.
Certified Student Course Curriculum - Version 2.0 Page 79
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Challenge Questions - Part III
Challenge Questions - Part III
1
1. Which tool in SQL Server provides management and security over the surface
area of local and remote instances on the SQL Server?
_____________________________________________________________
2. List at least three properties you can view and/or configure using the Server
Properties window.
_____________________________________________________________
_____________________________________________________________
_____________________________________________________________
1
SQL Server Fundamentals Lab Exercise - Configuring the SQL Server Properties
Page 80 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Lab Exercise - Configuring the SQL Server Properties
1
1. Use SQL Server Management Studio to review the facet properties of your SQL
Server instance. Ensure all unnecessary properties are disabled. (page 67).
2. View the server properties of your SQL Server instance and answer the following
questions:
What platform is being used by your server? _______________________
What is the maximum server memory (MB)?_______________________
What is the database location for your Data and Log files?
_________________________________________________________
_________________________________________________________
1
Certified Student Course Curriculum - Version 2.0 Page 81
Copyright 2010 Sage Software, Inc. All rights reserved.
Lesson 6
SQL Server Fundamentals
Exploring and Maintaining Your Data
61
After installing SQL Server, you can begin viewing, exploring, and maintaining your
data. In this lesson, you will learn to explore and configure your databases within
SQL Server as well as create tables.
The topics in this lesson include:
Viewing Databases Components
Viewing and Configuring Database Properties
Creating a Table
Running Queries
Working with Query Execution Plans
SQL Server Fundamentals Viewing Databases Components
Page 82 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Viewing Databases Components
1
SQL Server Management Studio allows you to view database components, such as
tables, columns, keys, constraints, triggers, indexes, and statistics.
1
Steps for Viewing Databases Components
In following steps, you will become familiar with viewing database components such
as tables and indexes.
1. In SQL Server Management Studio, expand the Databases node.
Certified Student Course Curriculum - Version 2.0 Page 83
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Viewing Databases Components
Viewing Databases Components (continued)
1
2. Expand your database node.
3. Expand the Tables node and explore the various components, such as the
columns, keys, constraints, indexes, and statistics.
4. In this example, we will also expand the Columns node for a specific table.
SQL Server Fundamentals Viewing Databases Components
Page 84 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Viewing Databases Components (continued)
1
5. Double-click the Sort Field column. The properties for the tables column
displays in the Column Properties window.
Certified Student Course Curriculum - Version 2.0 Page 85
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Viewing Databases Components
Viewing Databases Components (continued)
1
6. Similarly, you can access the properties for the keys, constraints, indexes, and
statistics for the selected table.
This example shows the Index Properties window that was accessed by double-
clicking the KPRIMARY_ES_DashboardSelectionListWrk index under the
Indexes node.
Activity
In the following activity, determine the index type for the dbo.AP_ACHCeckEntry
table.
1. If you are not currently in SQL Server Management Studio, access it now and log
into SQL Server if prompted.
2. Also make sure you are in the Object Explorer (View menu > Object Explorer.)
3. In SQL Server Management Studio, expand the Sage_SQL server node.
4. Expand the Databases node.
5. Expand the mas500_app node.
6. Expand the Tables node and expand the dbo.tapACHOptions node.
7. Expand the Indexes node and double-click the primary key index.
8. Review the properties of the index. What is the index type?
____________________________________________________
9. Close the Index Properties window.
SQL Server Fundamentals Viewing and Configuring Database Properties
Page 86 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Viewing and Configuring Database Properties
1
You can use the Database Properties windows to view information about the
databases and also configure the databases if needed. In the following steps, you will
verify file locations, size, options, and permissions of a database.
Steps for Viewing and Configuring Database Properties
1. In SQL Server Management Studio, expand the server node.
2. Expand the Databases node.
3. Right-click the database you want to view the properties for and select Properties.
The General page gives you an overview of the database.
Certified Student Course Curriculum - Version 2.0 Page 87
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Viewing and Configuring Database Properties
Viewing and Configuring Database Properties (continued)
1
4. Select Files under the Select a page section.
The Files page displays where the physical location of the data files are stored.
Each database has two main files: Data (.mdf) and Logs (.ldf) files.
- The reason for this configuration is to record each transaction in the Log file
and then commit that transaction to the database.
- It is recommended that your Data and Log files are stored on separate drives
for performance, as well as data recovery in case of a server failure.
Make sure the Enable Autogrowth check box is selected.
- This allows the database to automatically grow as additional transactions are
added to the database. This option is accessed by clicking the button next to
the Autogrowth field in the Database files grid.
You can also change the size of the database on the Files page, by changing the
space allocated.
- You can only increase the size of the database here, you can not reduce it.
- You can later use the DBCC SHRINKDATABASE to reduce the size if
needed.
SQL Server Fundamentals Viewing and Configuring Database Properties
Page 88 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Viewing and Configuring Database Properties (continued)
1
5. Select the Filegroups page under the Select a page section.
The Filegroups page shows the different locations the database are stored in.
Each database has one PRIMARY filegroup that contains the startup information
for the database and is used to store data in each table.
You can set up secondary filegroups to store additional data. For example:
- If you are running out of hard drive space, you can spread the database on
different drives.
- You can set up filegroups for performance. For example, if the sales order
tables experience the most activity in the system, you may want to move those
tables to a different drive or RAID to balance the usage load.
Certified Student Course Curriculum - Version 2.0 Page 89
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Viewing and Configuring Database Properties
Viewing and Configuring Database Properties (continued)
1
6. Select Options under the Select a page section.
The Options page is used to set the options of the database.
- These options are automatically set for the Sage MAS 200 SQL database
when they are created within SQL Server.
Under the State section, you can restrict access when you are trying to make
changes to the database but do not want users to be able to log in while you are
making those changes.
- Access is restricted only to db_owner, dbcreator, or sysadmin users.
The Recovery model is important to view based on the way that you are backing
up your SQL Server on a nightly basis.
- The FULL recovery method uses database backups and transaction log
backups to provide complete protection against media failure. If one or more
data files are damaged, media recovery can restore all committed transactions.
In-process transactions are rolled back.
Important: Although the FULL recovery method is recommended, you must
carefully weigh the factors of your particular systems, setup, and environment.
SQL Server Fundamentals Viewing and Configuring Database Properties
Page 90 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Viewing and Configuring Database Properties (continued)
1
- The BULK_LOGGED recovery method gives you the ability to fully restore a
database and also provides you the best performance and least log space usage
for certain bulk operations. While this method may sound like the best
alternative, the log file in this scenario is large and requires more space and
time than the Full recovery method.
- The SIMPLE recovery method truncates or deletes the transaction log as soon
as the actions are performed against the database; therefore, when you use the
SIMPLE method, only full or differential backups are allowed. The log is not
needed after the transaction is complete. This recovery model is rarely used in
production databases, as the risk of loss of recently written changes is simply
too great.
- Note: This recovery method is not recommended for large implementations.
7. Select Change Tracking under the Select a page section.
This feature allows you to view only changes that have been made to user tables
in addition to information about the changes.
Certified Student Course Curriculum - Version 2.0 Page 91
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Viewing and Configuring Database Properties
Viewing and Configuring Database Properties (continued)
1
8. Select Permissions under the Select a page section.
The Permissions page is used to view and assign permissions to the database.
Extended properties allow you to describe objects in a database in more detail.
Extended properties can also be useful to outside database developers who need a
greater understanding of the object.
SQL Server Fundamentals Viewing and Configuring Database Properties
Page 92 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Viewing and Configuring Database Properties (continued)
1
9. Select Extended Properties under the Select a page section.
The Extended Properties page is used to view or modify extended properties to
database objects.
Certified Student Course Curriculum - Version 2.0 Page 93
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Viewing and Configuring Database Properties
Viewing and Configuring Database Properties (continued)
1
10. Select Mirroring under the Select a page section.
The Mirroring feature has not been tested with all Sage ERP products. If you
decide to use this feature, you should thoroughly test and verify that your database
mirror is functioning properly.
SQL Server Fundamentals Viewing and Configuring Database Properties
Page 94 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Viewing and Configuring Database Properties (continued)
1
11. Select Transaction Log Shipping under the Select a page section.
This feature allows you to send transaction log backups from a main database on a
primary server to one or more secondary databases on separate servers.
- Transaction backup logs are applied individually to the secondary databases.
12. Click Cancel to close the window.
Certified Student Course Curriculum - Version 2.0 Page 95
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Viewing and Configuring Database Properties
Viewing and Configuring Database Properties (continued)
1
Activity
Use the following activity to explore the properties of the Sage_SQL database.
1. Access SQL Server Management Studio from the Start menu > All Programs >
Microsoft SQL Server 2008 R2.
2. Make sure you are in the Object Explorer (View menu > Object Explorer).
3. In SQL Server Management Studio, expand the Sage_SQL server node.
4. Expand the Databases node.
5. Right-click the mas500_app node and select Properties.
6. On the General tab, determine the following:
Who is the database owner? ___________________________________
What is the size of the database?________________________________
7. Select Files under the Select a page section.
What does the autogrowth setting indicate?________________________
8. Select Filegroups under the Select a page section.
What is the name of the filegroup? _______________________________
9. Select Options under the Select a page section.
What is the recovery model? ___________________________________
10. Select Change Tracking under the Select a page section.
What is the setting for Auto Cleanup? ____________________________
11. Select Permissions under the Select a page section.
What is the user name for mas500_app? ___________________________
12. Select Extended Properties under the Select a page section.
What is the collation type? _____________________________________
13. Click Cancel to close the window.
SQL Server Fundamentals Creating a Table
Page 96 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Creating a Table
1
You may find the need to create a user-defined table that captures additional data for
records. You can accomplish this by creating a new table in SQL Server, and
establishing a relationship to a native table, and use the customization feature in your
Sage ERP software to add the input fields to the Sage ERP interface.
The following section demonstrates how to create a new SQL table that contains
customer comments.
Steps for Creating a Table
1. In SQL Server Management Studio, expand the Databases node and then expand
the database you are adding tables to.
2. Create a new table by right-clicking the Tables node and selecting New Table.
3. Create the columns for the table and define the data type and whether to allow
nulls.
4. Make sure to create a primary key by highlighting a row, right-clicking, and
selecting the Set Primary Key.
5. From the File menu, select Save Table_1 and provide a name for your table.
Certified Student Course Curriculum - Version 2.0 Page 97
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Creating a Table
Creating a Table (continued)
1
6. Click OK to save the table name and close the Choose Name window.
7. In SQL Server Management Studio, find your new table and right-click it.
Note: You may need to click the Refresh button on the Object Explorer pane to
see your table name.
8. Select Properties. The Table Properties window displays.
SQL Server Fundamentals Creating a Table
Page 98 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Creating a Table (continued)
1
9. Select the Permissions page under the Select a page section.
10. Click Search.
Click this button to
set the permissions
for the table.
Certified Student Course Curriculum - Version 2.0 Page 99
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Creating a Table
Creating a Table (continued)
1
11. In the Select Users or Roles window, click Browse.
12. Select the role to add and click OK.
13. In the Select Users or Roles window, click OK.
14. Select the permissions the user will have for this table.
15. Click OK.
16. Click Yes if prompted to save changes to the table and No if prompted to save
changes to any queries.
SQL Server Fundamentals Creating a Table
Page 100 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Creating a Table (continued)
1
17. You can now use the customize feature within your Sage ERP product to tie the
new table to a field.
18. If you need to modify the table, right-click the table name in Object Explorer and
select Design. The table displays in design mode as shown below.
Certified Student Course Curriculum - Version 2.0 Page 101
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Creating a Table
Creating a Table (continued)
1
Activity
In the following activity, you will create a table and save it.
1. If you are not already in SQL Server Management Studio, access it now. From the
Start menu > All Programs > Microsoft SQL Server 2008.
2. Expand the Database node and then expand the mas500_app node.
3. Right-click the Tables node and select New Table.
4. Create the following columns for the table:
CustKey as an integer data type. This is also the primary key.
Comment with character data type. The length should be 50 characters.
5. From the File menu, select Save Table_1 and enter as the
name for your table.
6. Click OK to save the table name and then close the Choose Name window.
7. In SQL Server Management Studio, find the tarCustComment table and right-
click it.
Note: The table may be listed at the bottom of table listing initially.
8. Select Properties and then select Permissions under the Select a page section.
9. Click Search to open the Select Users or Roles window.
10. Click Browse and select the (public) object. Click OK.
11. In the Select Users or Roles window, click OK.
12. On the Explicit tab, select all the check boxes in the Grant column.
13. Click OK.
SQL Server Fundamentals Running Queries
Page 102 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Running Queries
1
One of the most important features in Microsoft SQL Server Management Studio is
the ability to answer a wide variety of questions concerning the data in the database.
Microsoft SQL Server allows you to use queries to find data that answers a specific
question you may have as well as run stored procedures against the databases.
A query is a simple question or command represented in a SQL statement that allows
you to inquire on a table, or multiple tables, and display the results for you or create
and run stored procedures and views. You can manage, view, analyze, and modify
your databases.
Queries use a special form of SQL known as Transact-SQL, or T-SQL. T-SQL uses
declarative statements to specify the data that needs to be retrieved from the database.
Steps for Accessing the New Query Feature
1. In SQL Server Management Studio, on the toolbar, click New Query.
When you first enter the query window, you will see two panes:
- The pane to the left contains the Object Explorer, which displays the databases
attached to the SQL server, as well as common T-SQL statements that are
available.
Certified Student Course Curriculum - Version 2.0 Page 103
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Running Queries
Running Queries (continued)
1
- The pane on the right is where you enter the T-SQL statement to be executed.
The drop-down on the toolbar shows the database you are going to run the query
against. It is important to change this to the correct database before running any
queries against it. Select the correct database from the drop-down shown below.
If you run a query without first establishing a connection, the Connect to Server
window displays where you specify the database server and the login you will use
to connect to the server with.
The data or results that is returned from your executed query or program, appears
in the results pane at the bottom of the screen.
Query Statements
As mentioned previously, a query is simply a question represented in a format that
SQL Server can understand. We use queries to inquire on specific data, such as
specific columns or rows, within a table or tables and obtain a view of the results, or
alter the databases or tables within the databases.
The most common types of query statements are:
SELECT
INSERT
CREATE
DELETE
UPDATE
SQL Server Fundamentals Running Queries
Page 104 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Running Queries (continued)
1
A great way to learn SQL Select Statement is to create a view in SQL Server
Management Studio. A view displays the T-SQL statement created.
You can also use SQL Server Books Online as a tool. To quickly access information
regarding the statement you are creating, while building your statement in the query
feature, you can highlight the statement word, such as SELECT or UPDATE, and use
the Shift+F1 command.
You can also attend a SQL course through Microsoft Certified training courses or
local colleges to expand your knowledge on creating advanced SQL statements.
SELECT Statements
The SELECT statement is the most frequently used SQL command and is the basic
way to query data. The SQL syntax for the SELECT statement appears a lot like how
you might ask for the information in plain English.
The basic form of the SQL SELECT command is SELECT clause-FROM clause-
WHERE clause.
SELECT clause - Where you define the columns you want to include in your query
results.
FROM clause - Where you identify the table(s) that contain the date you need to
query.
WHERE clause - Where you list conditions (restrictions) that apply to the data you
want to retrieve.
UPDATE Statements
The UPDATE statement is used for making changes to existing records in a table.
The basic form of the SQL UPDATE command is UPDATE clause-SET clause-
WHERE clause.
UPDATE clause - Where you define the table to be updated.
SET clause - Where you identify the column to be updated, followed by and equal
sign, then the new value.
WHERE clause - Where you indicate the row that you want to the change to take
place.
Caution: Before running any UPDATE statements on your production databases,
make a backup of your databases and test the script on test data.
Certified Student Course Curriculum - Version 2.0 Page 105
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Running Queries
Running Queries (continued)
1
Note: You can also run a query by selecting Execute from the Query menu.
You can also modify your statement to include multiple tables.
SQL Server Fundamentals Running Queries
Page 106 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Running Queries (continued)
1
Activity
1. If you are not already in SQL Server Management Studio, access it now. From the
Start menu > All Programs > Microsoft SQL Server 2008 R2.
2. On the toolbar, click New Query.
3. At the database drop-down on the toolbar, select mas500_app.
4. Type the following query:



This query pulls the Customer Key, Customer ID, Customer Name, and Company
columns from the tarcustomer table and returns all rows were the Company ID is
SOA.
5. Click the Execute button on the toolbar.
6. Next, modify your statement to include the tarCustClass table.






Note: In this query we had to put the table name in front of the companyid column
because the companyid exists in both tarcustomer and tarcustclass tables.
7. Click the Execute button on the toolbar.
Certified Student Course Curriculum - Version 2.0 Page 107
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Working with Query Execution Plans
Working with Query Execution Plans
1
As you have learned, one of the strongest features of SQL Server Management Studio
is that it gives you the ability to write and execute queries. Another great feature is the
ability to view query execution plans in a graphical display. Graphical icons are used
to represent the execution of statements and queries, making it much easier to
understand the performance characteristics of a query.
Steps for Creating a Graphical Query Execution Plan
1. In SQL Server Management Studio, click New Query and type the T-SQL script
that you want to analyze.
Clicking the Display Estimated Execution Plan button parses the script and
generates an estimated plan.
Clicking the Include Actual Execution Plan button means you must execute the
script before generating the execution plan.
Display Estimated Execution Plan Include Actual Execution Plan
SQL Server Fundamentals Working with Query Execution Plans
Page 108 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Working with Query Execution Plans (continued)
1
2. For our example, we will click the Display Estimated Execution Plan button. The
graphical representation of the query displays in the lower portion of the SQL
Server Management Studio window on the Execution Plan tab.
Graphical execution plans are read from right to left and top to bottom.
If you have batches of queries, each query is analyzed and displayed, including
the cost of each query as a percentage of the total cost of the batch.
Certified Student Course Curriculum - Version 2.0 Page 109
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Challenge Questions - Part III
Challenge Questions - Part III
1
1. What is the quickest way to view the properties of a database in SQL Server?
_________________________________________________________
2. Which page in the Database Properties window is used to set the options of the
database?
_________________________________________________________
3. What are the three recovery models?
_________________________________________________________
_________________________________________________________
_________________________________________________________
4. Explain how to quickly create a table in SQL Server.
_________________________________________________________
_________________________________________________________
_________________________________________________________
SQL Server Fundamentals Lab Exercise - Viewing Database Properties
Page 110 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Lab Exercise - Viewing Database Properties
1
1. In SQL Server Management Studio, expand the mas500_app database node.
2. View the table properties for dbo.tarBatch. (page 82)
What is the filegroup name? _______________________________________
Is the table replicated? ____________________________________________
How many indexes are there? ______________________________________
What type of index is PK__tarBatch? ________________________________
3. View the properties of the mas500_app database. (page 86)
What does the autogrowth setting indicate?________________________
What is the recovery model? ___________________________________
What is the setting for Auto Cleanup? ____________________________
What is the user name for mas500_app? ___________________________
What is the collation type? _____________________________________
4. Create a new table in the mas500_app database called dbo.tapVendComments.
(page 96)
5. Create the following columns for the table:
VendKey as an integer data type. This is also the primary key.
Comment as a character data type. The length should be 50 characters.
Certified Student Course Curriculum - Version 2.0 Page 111
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Lab Exercise - Working with Queries
Lab Exercise - Working with Queries
1
1. In SQL Server Management Studio, create a new query using the mas500_app
database. (page 102)
2. Type a query to pull the Vendor Key, Customer ID, Vendor Name and Company
from the tapvendor table and returns all rows where the Company ID is SOA.
3. Execute the query.
4. Next, modify your statement to include the tapVendClass table. (page 106)
5. Click the Execute button on the toolbar.
6. View the query is a graphical format. (page 107)
Page 112 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Lesson 7
SQL Server Fundamentals
Managing Your Databases
71
One of the most powerful features in SQL Server Management Studio are the
management options. The management options allow you to create management
plans, define and enforce policies, manage SQL Server workload and critical system
resource consumption, review logs, and review detailed status of processes and
current user connections.
The topics in this lesson include:
Using the Management Options
Policy Management
Data Collection
Resource Governor
Maintenance Plans
SQL Server Logs
Database Mail
Certified Student Course Curriculum - Version 2.0 Page 113
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Using the Management Options
Using the Management Options
1
The Management node in SQL Server Management Studio gives you access to Policy
Management, Data Collection, Resource Governor, Maintenance Plans, SQL Server
Logs, Database Mail, Distributed Transaction Coordinator, and the Legacy options
(options implemented prior to SQL Server 2008).
1
SQL Server Fundamentals Policy Management
Page 114 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Policy Management
1
The Policy Management option allows you to define and enforce policies for
configuring and managing SQL Server across an enterprise. The policies you define
can be used by one or more SQL Server instances.
Note: Policy Management is a new option in SQL Server 2008.
Expand the Policy Management node to view the policies, conditions, and facets
for a server.
- Policies: Set to enforce or check compliance with conditions. Policies are
created for one condition.
- Conditions: Property expressions that evaluate to True or False. This
indicates the state of a facet.
- Facets: Pre-defined sets of properties that can be managed.
To create a new
policy, right-click the
Policies node and
select New Policy.
You can right-click
the Conditions
node to create a
new condition.
Use this section to
build the
expression for the
condition.
Certified Student Course Curriculum - Version 2.0 Page 115
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Data Collection
Data Collection
1
Right-clicking the Data Collection node under the Management node allows you to
perform the following:
Access the Configure Management Data Warehouse wizard to create a
management data warehouse, configure logins, enable data collection, and start
the System Data Collection Sets.
Access the Log File Viewer.
Start Powershell.
Access Management Data Warehouse reports, such as Server Activity History,
Disk Usage Summary, and Query Statistics History.
Refresh the data collection.
SQL Server Fundamentals Resource Governor
Page 116 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Resource Governor
1
The Resource Governor option is a new feature in SQL Server 2008 that allows you
to manage SQL Server workload and critical system resource consumption. You can
specify limits on the amount of CPU and memory that the incoming sessions to the
SQL Server can use.
Note: Resource Governor is available only on Enterprise, Developer, and Evaluation
editions of SQL Server.
With Resource Governor, you can:
Classify incoming connections and route the workloads to a specific group.
Monitor resource usage for each workload in a group.
Pool resources and set limits on CPU usage and memory allocation, preventing
run-away queries.
Associate grouped workloads with a specific pool of resources.
Identify and set priorities for workloads.
Certified Student Course Curriculum - Version 2.0 Page 117
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Maintenance Plans
Maintenance Plans
1
With this option, you can create a series of tasks to optimize your database, regularly
back up your databases, etc. The Maintenance Plan option under the Management
node displays any maintenance plans that have been created using the Maintenance
Plan Wizard. For more information, seeCreating Maintenance Plans on page 195.
SQL Server Fundamentals SQL Server Logs
Page 118 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Logs
1
The SQL Server Logs option under the Management node displays the activity from
the time the SQL Server is started until it is shut down.
SQL Server creates a new log every time you stop and restart the server.
It is a good practice to review the logs on a regular basis.
Certified Student Course Curriculum - Version 2.0 Page 119
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals SQL Server Logs
SQL Server Logs (continued)
1
To view the logs, expand the Management node and expand the SQL Server Logs
node. Double-click a log to view it in the Log File Viewer window.
SQL Server logs:
- Record processes that have been completed successfully, such as backup and
restore operation, batch commands, and scripts.
- Are used to detect any problems with SQL Server, such as automatic recovery
messages.
Alerts can be created based on specific events that are recorded to the logs.
The last six most recent logs are retained by default.
- To retain more logs, modify in the SQL Server Logs configure options.
SQL Server Fundamentals SQL Server Logs
Page 120 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Logs (continued)
1
Activity
1. If you are not in SQL Server Management Studio, access it now from the Start
menu > All Programs > Microsoft SQL Server 2008 R2.
2. Make sure you have the Object Explorer pane open (View menu > Object
Explorer).
3. In the SQL Server Management Studio, expand the Management node and then
expand the SQL Server Logs node.
4. Right-click the Current log, and then select View SQL Server Log.
5. In the Log File Viewer window, expand the SQL Server node, if it is not already
expanded. Select the check box to view the current and archived log items.
6. Take a few minutes to view the log entries.
7. Click Close.
Certified Student Course Curriculum - Version 2.0 Page 121
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Database Mail
Database Mail
1
A mail profile is required by Database Mail to start a mail session and send
notification by email or pager. A Database Mail session is started every time the SQL
Server Agent is started. You can create the profile with a mail client, such as
Microsoft Outlook, that is installed locally on the SQL Server computer.
For more information about Database Mail, refer to the Database Mail How-to Topics
article on the MSDN website at:
http://msdn.microsoft.com/en-us/library/ms188298.aspx
You can set up Database Mail by right-clicking the Database Mail node in SQL
Server Management Studio.
Depending on whether you are creating a new account or managing an existing
one, the Database Mail Configuration Wizard guides you through the steps.
SQL Server Fundamentals Database Mail
Page 122 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Database Mail (continued)
1
If you plan to send notifications to operators by email or pager, you must:
- Have a mail server that is extended SMTP-compliant
- Configure a mail profile for SQL Server Agent to use to connect to your mail
server
- Have a mail server that is able to communicate with your pagers
- Make sure it works with Microsoft Exchange; however, there are some known
issues with SMTP and Groupwise
For more information about Database Mail, refer to the following:
http://msdn.microsoft.com/en-us/library/ms175887.aspx
Certified Student Course Curriculum - Version 2.0 Page 123
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Challenge Questions - Part IV
Challenge Questions - Part IV
1
1. Which option under the Management node allows you to enforce policies for
configuring and managing SQL Server across an enterprise?
_________________________________________________________
2. Which option under the Management node allows you to manage SQL Server
workload and system resource consumption?
_________________________________________________________
3. What does the SQL Server Logs option under the Management node allow you to
do?
_________________________________________________________
_________________________________________________________
_________________________________________________________
_________________________________________________________
SQL Server Fundamentals Lab Exercise - Exploring the Management Node Options
Page 124 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Lab Exercise - Exploring the Management Node Options
1
1. In SQL Server Management Studio, on the Object Explorer, expand the
Management node. (page 113).
2. Take a few minutes to explore all the tools under the Management node.
3. View the Current log activity in the Log File Viewer window. (page 118)
Certified Student Course Curriculum - Version 2.0 Page 125
Copyright 2010 Sage Software, Inc. All rights reserved.
Lesson 8
SQL Server Fundamentals
Understanding the SQL Server Agent
81
Another powerful tool in the SQL Server Management Studio is the SQL Server
Agent, which can be used to schedule tasks (called jobs). This lesson also discusses
creating alerts and operators as well as how to view job activity in your system.
The topics in this lesson include:
Using the SQL Server Agent
Understanding Alerts\
Understanding Operators
Using the Job Activity Monitor
SQL Server Fundamentals Using the SQL Server Agent
Page 126 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Using the SQL Server Agent
SQL Server Agent is a service that monitors SQL Server and creates alerts, jobs,
schedules, operators, proxies, and error logs. This service should always be running to
schedule index rebuilds, nightly backups, alerts, and schedule any other scheduled
task.
Some things to note about SQL Server Agent:
It has a separate security identity.
Can send mail and alerts.
SQL Server Agent is not set to start automatically by default.
Jobs have history.
Access the options under the SQL Server Agent by right-clicking the SQL Server
Agent node or expanding the node in SQL Server Management Options.
SQL Server Agent is responsible for:
- Running SQL Server tasks scheduled to occur at specific times or intervals.
- Detecting specific conditions for which administrators have defined an action,
such as alerting someone through pages or email, or a task that will address
the conditions.
- Running replication tasks determined by administrators.
Certified Student Course Curriculum - Version 2.0 Page 127
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Using the SQL Server Agent
Using the SQL Server Agent (continued)
1
The SQL Server Agent should be set up to start automatically. There are several
ways to start and/or configure the SQL Server Agent:
- Right-click the SQL Server Agent node, and then select Start.
- Configure and start the SQL Server Agent from the Windows Services
feature.
- Configure and start the SQL Server Agent service from the Server Manager
icon in the system tray of the server.
- On the General tab in SQL Server properties.
For more information, refer to the SQL Server Agent article on the MSDN
website at:
http://msdn.microsoft.com/en-us/library/ms189089.aspx
SQL Server Fundamentals Understanding Jobs
Page 128 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Understanding Jobs
1
Jobs are tasks or a series of steps that are performed by SQL Server Agent. They can
include SQL Server Integration Services (SSIS) jobs, scheduled backups and database
maintenance, or Transact-SQL Scripts.
Steps for Creating a New Job
1. In SQL Server Management Studio, expand the SQL Server Agent node, and then
expand the Jobs node.
2. Right-click the Jobs node and then select New Job. The New Job window
displays.
On the General page you can enter the name, category, owner, and description of
the job.
3. Enter a job name, the owner of the job, category and description.
To prevent a job from
running, clear the
Enabled check box.
You can categorize
the jobs into different
groups for easier
administration.
Certified Student Course Curriculum - Version 2.0 Page 129
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Understanding Jobs
Understanding Jobs (continued)
1
4. Select Steps under the Select a page section.
The Steps page provides a listing of each step the job will take.
- You can edit a step and look at the details behind the step.
The buttons at the Command section allow you to load the command from a file,
select, copy, and paste the text.
To create a new job step, click New.
Click this button to
check the syntax of
the command.
SQL Server Fundamentals Understanding Jobs
Page 130 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Understanding Jobs (continued)
5. Click New to define a new step for the job.
6. At the Step name field, enter the name of the step.
7. At the Type field, set the subsystem that the job step uses. The Run as field allows
you to set the proxy account for the job step.
8. At the Command field, enter the command needed to perform the step, if
applicable.
9. Click Parse to check the syntax of the command.
Certified Student Course Curriculum - Version 2.0 Page 131
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Understanding Jobs
Understanding Jobs (continued)
1
10. Click Schedules under the Select a page section.
The Schedules page lists the schedules for this job and allows you to specify the
frequency of the job's occurrence.
You can create a new schedule to add to the job.
A job and schedule must have the same owner. You can only pick from schedules
that you own.
You can remove a schedule from the job. The job is deleted from the database if
no other jobs use the schedule.
11. Select the Alerts page under the Select a page section.
The Alerts page lists the alerts for this job.
You can create a new alert for the job or modify an existing alert.
You can also remove an alert from the job.
SQL Server Fundamentals Understanding Jobs
Page 132 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Understanding Jobs (continued)
1
Alerts can also be accessed from the Alerts node under the SQL Server Agent
node in the SQL Server Management Studio window. Alerts are discussed in more
detail later in this lesson.
12. Select Notifications under the Select a page section.
The Notifications page determines who is contacted after the job is run. You can
also notify someone if the job fails.
- It is recommended that an e-mail be sent daily to someone who will review if
the job ran successfully.
- If the client does not have a full time IT person, set yourself up as the operator.
13. Select Targets under the Select a page section.
You can use the Targets page to select which server to run the job on. You can
target the job on the local server or run the job on one or more servers.
14. Click OK to create the new job.
Certified Student Course Curriculum - Version 2.0 Page 133
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Understanding Jobs
Understanding Jobs (continued)
1
15. You can then view or edit the job by expanding the Jobs node and double-clicking
the job name.
SQL Server Fundamentals Understanding Jobs
Page 134 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Understanding Jobs (continued)
1
Activity
1. If you are not in SQL Server Management Studio, access it now from the Start
menu > All Programs > Microsoft SQL Server 2008 R2.
2. Make sure you have the Object Explorer pane open (View menu > Object
Explorer).
3. In SQL Server Management Studio, expand the SQL Server Agent node and then
expand the Jobs node.
4. Right-click the Jobs node and then select New Job. The New Jobs window
displays.
5. At the Name field, type .
6. Select Steps under the Select a page section.
7. Click New to define a new step for the job.
8. In the New Job Step window that displays, enter .
9. At the Command field, enter the following:



10. Click Parse to check the syntax of the command and then OK when prompted that
the command was parsed successfully.
11. At the Database field, select mas500_app.
12. Select Schedules under the Select a page section.
13. Click New to create a schedule.
14. In the New Job Schedule window that displays, enter
at the Name field.
15. At the Occurs field, select Daily. Keep the Occurs once at field set to .
16. Click OK and then click OK again in the Job Properties window.
17. Under the Jobs node, you can see that the Data Import job is created.
Certified Student Course Curriculum - Version 2.0 Page 135
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Understanding Alerts
Understanding Alerts
1
1
An alert is an action to be done when a specific event occurs. When errors, messages,
or events are generated by SQL Server, they are recorded in the error log, and then
matched to an existing alert to determine if an action should take place. The alert can
be defined to take such actions as sending an e-mail, paging an operator, or running a
job to address the problem.
Steps for Creating Alerts
1. Under the SQL Server Agent node, right-click Alerts, and then select New Alert.

On the General page, identify the alert name, the error number, or severity that
will trigger the alert. Also identify the database that the error will occur on to
trigger the alert.
SQL Server Fundamentals Understanding Alerts
Page 136 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Understanding Alerts (continued)
1
2. Select Response under the Select a page section.
On the Response page, you can specify if a particular job should be executed, and
the operator to notify for the alert.
3. Select the Notify operators check box.
4. Select the E-mail check box for the operator.
5. Click Cancel.
6. Click OK.
Certified Student Course Curriculum - Version 2.0 Page 137
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Understanding Alerts
Understanding Alerts (continued)
1
Activity
1. If you are not in SQL Server Management Studio, access it now from the Start
menu > All Programs > Microsoft SQL Server 2008 R2.
2. Make sure you have the Object Explorer pane open (View menu > Object
Explorer).
3. In the SQL Server Management Studio window, right-click the SQL Server Agent
node.
4. Right-click Alerts and then select New Alert.
5. At the Name field, enter .
6. At the Type field, select SQL Server event alert.
7. At the Database name field, select mas500_app.
8. Select the Severity option and then select 024 - Fatal Error: Hardware Error at
the drop-down.
9. Click OK.
SQL Server Fundamentals Understanding Operators
Page 138 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Understanding Operators
1
1
To be notified when a job or alert is executed, it is important to create an Operator.
Operators are e-mailed or paged when a specific event occurs on the server.
Steps for Creating Operators
Use the following steps to create a new operator.
1. In the SQL Server Management Studio window, right-click the SQL Server Agent
node, and then select Start, if the SQL Server Agent has not started.
2. Under the SQL Server Agent node, right-click Operators, and then select New
Operator.
Certified Student Course Curriculum - Version 2.0 Page 139
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Understanding Operators
Understanding Operators (continued)
1
You can enter the operator's name and the following additional information:
- E-mail address
- Pager e-mail name
- Net send address - this is the operator's workstation IP address that is used to
send a message to the screen.
Additionally, you can restrict the times the operator can receive pager
notifications.
When setting up an operator, make sure to test the connection after it has been
entered.
3. Enter the operators name and email address. You can also enter a net send
address and pager name.
4. In the Pager on duty schedule section, set the times at which the pager is to be
active. In the Workday begin/end fields, enter the times to send messages to the
pager.
SQL Server Fundamentals Understanding Operators
Page 140 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Understanding Operators (continued)
1
5. Select Notifications under the Select a page section.
On the Notification page, you can identify what events the operator can be
notified on, as well as whether to notify the operator by email, pager, or net send.
6. Select the method for notifying the operator for each event.
7. Click OK.
Certified Student Course Curriculum - Version 2.0 Page 141
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Understanding Operators
Understanding Operators (continued)
1
Activity
1. If you are not in SQL Server Management Studio, access it now from the Start
menu > All Programs > Microsoft SQL Server 2008 R2.
2. Make sure you have the Object Explorer pane open (View menu > Object
Explorer).
3. In the SQL Server Management Studio window, right-click the SQL Server Agent
node.
4. Right-click Operators and then select New Operator.
5. At the Name field, enter .
6. At the E-mail name field, enter .
7. Select Notifications under the Select a page section.
8. At the Hardware alert event, select the E-mail check box and then click OK.
SQL Server Fundamentals Using the Job Activity Monitor
Page 142 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Using the Job Activity Monitor
1
Use the Job Activity Monitor to view the current activity of your SQL Server Agent
jobs.
1
Steps for Viewing a Job
1. Under the Jobs node, double-click Job Activity Monitor. The Job Activity
2. Monitor window displays with the current job activity.
Right-click a job in the grid to:
- Start the job and run all the job steps.
- Start the job and start at a particular step.
- Disable or enable the job.
- Refresh the job.
- Delete the job.
- View the job history.
- View the properties of the job.
Click Filter to limit
the jobs that display.
Your current jobs
display here.
Certified Student Course Curriculum - Version 2.0 Page 143
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Using the Job Activity Monitor
Using the Job Activity Monitor (continued)
1
3. Double-click the last job in the list. The job displays in the Job Properties window.
4. Click OK and then click Close to close the Job Activity window.
Activity
1. Under the Jobs node in SQL Server Management Studio, double-click Job
Activity Monitor.
2. In the Job Activity Monitor window, double-click the job you created in a
previous activity. The job displays in the Job Properties window.
3. Take a few minutes to view the steps and properties of the job.
4. Click OK and then close the Job Activity Monitor window.
SQL Server Fundamentals Viewing SQL Server Agent Properties
Page 144 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Viewing SQL Server Agent Properties
1
1
The SQL Server Agent Properties window displays the current state of the SQL
Server Agent service.
Steps for Viewing SQL Server Agent Properties
1. Right-click the SQL Server Agent node in SQL Server Management Studio, and
then select Properties.
Use the General page to define whether SQL Server and/or the SQL Server Agent
services should be restarted automatically and specify the file name for the error
log.
It is recommended that both the auto restart check boxes are selected.
SQL Server Agent allows you to schedule tasks.
2. On the General page select both of the auto restart check boxes.
Select this check box to
include execution trace
messages in the error
log. Note that the
log file requires more
disk space if you select
this option.
Certified Student Course Curriculum - Version 2.0 Page 145
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Viewing SQL Server Agent Properties
Viewing SQL Server Agent Properties (continued)
1
3. Select Advanced under the Select a page section.
On the Advanced page, define a different SQL Server to forward application log
events to, including the type of events, such as, unhandled, all, or those with a
specific severity level.
You can also select options for defining the conditions under which SQL Server
Agent runs jobs scheduled to run on the Idle CPU schedule.
- The Define idle CPU condition field defines the conditions the CPU is
considered idle, such as percentage of CPU usage and the amount of time the
average CPU must fall below before jobs are run on the Idle CPU schedule.
4. Select the Alert System page under the Select a page section.
On the Alert System page, define settings for specifying the Mail profile.
You can also define settings for sending pager e-mails to an operator.
5. Select Job System under the Select a page section.
On the Job System page, define the maximum number of seconds that SQL Server
Agent will wait for a job to finish executing before shutting down.
You can also set a non-administrator proxy account for SQL Server Agent.
6. Select Connection under the Select a page section.
On the Connection page, identify the connection type for the SQL Server Agent to
connect to the SQL Server.
If Windows Authentication is selected, the user account specified as the SQL
Server Agent service startup account must be a member of the sysadmin role in
SQL Server.
You can also specify an alias to use to connect to the local instance of the SQL
Server.
7. Select History under the Select a page section.
On the History page, define settings for limiting the size of the job history log to
avoid filling msdb by controlling the row size and number of rows written to the
log file.
You can also define the maximum number of seconds that SQL Server Agent will
wait for a job to finish executing before shutting down.
8. Click Cancel to close the SQL Server Agent Properties window.
SQL Server Fundamentals Viewing SQL Server Agent Properties
Page 146 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Viewing SQL Server Agent Properties (continued)
1
Activity
1. If you are not in SQL Server Management Studio, access it now from the Start
menu > All Programs > Microsoft SQL Server 2008 R2.
2. Make sure you have the Object Explorer pane open (View menu > Object
Explorer).
3. In the SQL Server Management Studio window, right-click the SQL Server Agent
node and select Properties.
4. Make sure both the Auto restart check boxes are selected on the General page.
5. Select Advanced under the Select a page section.
6. Select the Define idle CPU condition check box and then enter at the Average
CPU usage falls below field.
7. Select Job System under the Select a page section.
8. Enter seconds for the shutdown time-out interval.
9. Select History under the Select a page section.
10. Enter as the maximum job history log size value.
11. Click OK.
Certified Student Course Curriculum - Version 2.0 Page 147
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Challenge Questions - Part V
Challenge Questions - Part V
1
1. Which node in SQL Server Management Studio contains tools that allow you to
create alerts, jobs, and operators?
____________________________________________________________
2. Explain briefly how to create a job and a step within a job.
____________________________________________________________
____________________________________________________________
____________________________________________________________
____________________________________________________________
SQL Server Fundamentals Lab Exercise - Working with SQL Server Agent
Page 148 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Lab Exercise - Working with SQL Server Agent
1
1. Access SQL Server Agent in SQL Server Management Studio. (page 126)
2. Create a job that contains a step for importing nightly orders from a website.
(page 128)
3. Create an operator using your name and email address. (page 135)
4. Create an alert that will alert you when there is a hardware error. Set this alert for
all databases. (page 135)
5. View the job you created in the Job Activity Monitor. (page 135)
6. Access the properties for the SQL Server Agent and make the following settings:
(page 144)
Make sure both the autostart check boxes are selected on the General tab.
Change the idle CPU to 15%.
Change the shutdown time-out interval to 30 seconds.
Limit the size of the job history log to 2000 rows.
Certified Student Course Curriculum - Version 2.0 Page 149
Copyright 2010 Sage Software, Inc. All rights reserved.
Lesson 9
SQL Server Fundamentals
Optimizing and Fine-Tuning Your Databases
91
There are many tools within Microsoft SQL Server to help you fine-tune and optimize
your databases. You can use the SQL Server Profiler, Database Engine Tuning
Advisor, and Performance Monitor. This section also covers the importance of tuning
your indexes.
The topics in this lesson include:
Using Microsoft SQL Server Profiler
Using the Database Engine Tuning Advisor
Monitoring Performance
Monitoring Activity
Dynamic Management Views
SQL Server Reports
Other Performance Management Tools
SQL Server Fundamentals Using Microsoft SQL Server Profiler
Page 150 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Using Microsoft SQL Server Profiler
1
Microsoft SQL Server Profiler a tool that allows you to monitor events occurring
within Microsoft SQL Server. For example, you can monitor a production
environment to see which stored procedures are hampering performance by executing
too slowly. SQL Server Profiler can be used by a database administrator to diagnose
code or index bottlenecks in the system.
This tool is extremely helpful for the following reasons:
Monitor the performance of a SQL Server
Identify slow-executing queries
Debug SQL errors
Determine where SQL or Sage MAS 200 SQL is pulling the data from
Traces CPU, memory, I/O load, and duration
SQL Server Profiler allows you to monitor only the events you are interested in
tracking. You can add filters on many fields including login name, SQL Server, and
Process ID.
Note: It is not recommended to run SQL Server Profiler for long durations on the
production server due to decreases in SQL performance.
Steps for Creating a Trace
A trace log can be used to assist a database administrator in understanding why a
problem is occurring. After you have traced events, SQL Server Profiler allows
captured event data to be replayed against an instance of SQL Server, thereby
effectively re-executing the saved events as they occurred originally.
1. In SQL Server Management Studio, select SQL Server Profiler from the Tools
menu.
Note: You can also access this tool from the Start menu > Programs > Microsoft
SQL Server 2008 > Performance Tools > SQL Server Profiler.
2. When prompted to log onto the SQL Server, enter your login and password.
Certified Student Course Curriculum - Version 2.0 Page 151
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Using Microsoft SQL Server Profiler
Using Microsoft SQL Server Profiler (continued)
1
3. The Trace Properties window displays.
On the General tab, enter the trace name.
You can also select the file location or table to save the trace to for review later.
4. Enter a name for the trace operation.
5. At the Use the template drop-down, select Tuning.
6. Verify the trace provider name is your server name.
7. Select the Save to file check box.
8. In the Save As window, select the Desktop icon and then click Save.
9. Make sure the Enable file rollover check box is cleared.
10. Change the value at the Set maximum file size field as needed.
SQL Server Fundamentals Using Microsoft SQL Server Profiler
Page 152 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Using Microsoft SQL Server Profiler (continued)
1
11. Click the Events Selection tab.
The Events Selection tab allows you to specify what you want to trace in SQL.
12. Select the needed events.
13. Scroll over and click the Database Name column heading to create a filter. The
Edit Filter window displays.
14. Expand the Like node, enter a database name, and then press the ENTER key.
15. Click OK to close the Edit Filter window.
Click this button to
choose which data
will be returned.
Click this button to
set up a filter to
reduce extra lines
from appearing in
the trace file.
Select this
check box to
exclude empty
rows from the
search.
Certified Student Course Curriculum - Version 2.0 Page 153
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Using Microsoft SQL Server Profiler
Using Microsoft SQL Server Profiler (continued)
1
16. From the Window menu, clear the Auto scroll option.
17. Click Run to start the trace.
18. A window similar to the following displays.
SQL Server Fundamentals Using Microsoft SQL Server Profiler
Page 154 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Using Microsoft SQL Server Profiler (continued)
1
The top rows show the events that were tracked.
By selecting a row, you can view the T-SQL statement that was executed in the
bottom section of the screen.
You can also view how long the event took in the Duration column.
- To review performance issues look for statements that exceed 10000
miliseconds.
- Some lookups have timeouts of 60000 miliseconds to prevent a strain on the
SQL Server.
19. Open a window in the Sage ERP software and observe the trace activity that
occurs.
Certified Student Course Curriculum - Version 2.0 Page 155
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Using the Database Engine Tuning Advisor
Using the Database Engine Tuning Advisor
2
Use the Database Engine Tuning Advisor to analyze the workload of one or more
databases. The workload of your Sage ERP databases may expand over time as more
users and data are added to them. This will begin to affect the performance of query
processing. The major job of the database administrator is spent on tuning database
performance and improving query processing time. This may include:
Adding new indexes
Tuning existing indexes
Identifying possible logic changes
In this section we will discuss tuning of the databases using indexes.
The Database Engine Tuning Advisor in the SQL Server Profiler feature is an easy to
use and understand wizard-based tool that allows you to build an optimal set of
indexes and statistics for your database.
The Database Engine Tuning Advisor can:
Give recommendations of the optimal combination of indexes for a database
given a workload, by using the query optimizer to analyze the queries in the
workload.
Do what if analysis of proposed changes, including index usage, distribution of
queries among tables, and performance of queries in the workload.
Propose recommendations of how to tune the database for your queries.
Before running the Database Engine Tuning Advisor:
Create a trace of the data using SQL Server Profiler.
- When building the trace, make sure you capture a good representation of
normal database activity.
Once you have the trace configured the way you want, the wizard can analyze the
workload and recommend index configurations.
SQL Server Fundamentals Using the Database Engine Tuning Advisor
Page 156 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Using the Database Engine Tuning Advisor (continued)
2
After running the Database Engine Tuning Advisor you can:
- Prior to implementing the recommendations, verify they are valid and will
truly optimize the combination of indexes by studying the application.
- Implement the suggestion immediately.
- Schedule the change to be implemented later by creating a SQL Server job.
- Save the change to a SQL script and execute it manually or transport it to
another server.
Filegroups
An additional way for database optimization is to create additional filegroups. Each
database has one PRIMARY filegroup. This contains the startup information for the
database and is used to store data in each table.
You can set up secondary file groups to store additional data.
There are two primary reasons for setting up secondary filegroups.
- First, if you are running out of hard drive space, you can spread the database
on different drives.
- Second, you can set up filegroups for performance. For example, if the sales
order tables are utilized the most in the system, consider moving those tables
to a different drive or RAID to balance the usage load.
Steps for Analyzing a Workload
Use the following steps for analyzing a workload.
1. In the SQL Server Profiler window, select Database Engine Tuning Advisor from
the Tools menu.
2. If prompted to log on to the server, enter your password and click Connect in the
Connect to Server window.
Certified Student Course Curriculum - Version 2.0 Page 157
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Using the Database Engine Tuning Advisor
Using the Database Engine Tuning Advisor (continued)
2
3. In the Database Engine Tuning Advisor window that displays, maximize the
window.
Trace files, trace tables, or Transact-SQL scripts can be used for the workload
input for tuning databases.
4. In the Workload section, select the File option and then click the Browse for a
workload file button.
5. Browse to the .trc file that you created previously, such as Open Customer
Screen.trc. Click Open.
6. In the Select databases and tables to tune section, select the appropriate Sage ERP
database.
7. Click the Tuning Options tab and then click Advanced Options.
8. In the Advanced Tuning Options window that displays, select the Define max
space for recommendations (MB) check box and enter an amount.
Click this button to
to start the analysis
process after
selecting the
database and tables,
which trace file/
table or T-SQL
script to use, and
the tuning options
selected on the
Tuning Options tab.
SQL Server Fundamentals Using the Database Engine Tuning Advisor
Page 158 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Using the Database Engine Tuning Advisor (continued)
2
Note: In this example, the advanced option is set this way because the database
that is being tuned has a large number of schema objects. Otherwise, we would
exceed the default allowance of space.
9. Click OK to close the Advanced Tuning Options window.
10. From the toolbar of the Database Engine Tuning Advisor window, click the Start
Analysis button.
11. Observe the tuning progress that occurs and make note of any recommendations.
Certified Student Course Curriculum - Version 2.0 Page 159
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Monitoring Performance
Monitoring Performance
2
The Performance Monitor tool in SQL Server Profiler can be used for tuning your
SQL server, as well as troubleshoot SQL Server issues. In using this tool, you may
find:
You need to set up additional filegroups
Insufficient processor resources
Improper server configurations
Application code bottlenecks
Note: Running these performance monitors during heavy production time can cause
additional system slowdowns.
Steps for Monitoring Performance
1. In the SQL Server Management Studio window, select SQL Server Profiler from
the Tools menu.
2. Close the Trace Properties window that displays.
SQL Server Fundamentals Monitoring Performance
Page 160 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Monitoring Performance (continued)
2
3. In the SQL Server Profiler window, select Performance Monitor from the Tools
menu. The Performance window displays.
You can select the object you want to monitor from the Counter Logs, Trace Logs,
and Alerts categories.
There are specific counters that should be monitored.
4. Expand the Performance Logs and Alerts node.
5. Right-click Counter Logs and select New Log Settings.
Certified Student Course Curriculum - Version 2.0 Page 161
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Monitoring Performance
Monitoring Performance (continued)
2
6. Enter a name for the log and click OK.
7. In the window that displays, click Add Counters.
Use the Add Counters window to select the object you want to monitor and the
counter to use.
8. In the Add Counters window, at the Performance object drop-down, select the
object that you want to view counters for.
9. In the counters list, select the counter(s) to use for monitoring the system. Click
Close.
10. Click OK and then click Yes if prompted to create the PerLogs file.
Depending on
which object you
select at this drop-
down, the
associated counters
display in the list
below.
Click this button for
an explanation of
the counter.
SQL Server Fundamentals Monitoring Performance
Page 162 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Monitoring Performance (continued)
2
Recommended Objects - Counter - Instance to Monitor
Processor - % Processor Time - Each Processor or _Total
- The percentage of time the processors are peaked or near peak represents slow
performance for your users during those periods.
- If these occur frequently, it may be indicative of server configuration issues,
insufficient processor resources, or even application code bottlenecks.
SQL Server: Cache Manager - Cache Hit Ratio - Prepared SQL Plans, Procedure
Plans, Adhoc Sql Plans
- This setting generally indicates whether or not you have enough memory
dedicated to SQL Server.
- The counter results should consistently exceed 70%, with most at or above
90%.
- If results are lower than this, you either do not have enough server memory or
you do not have enough of the physical memory dedicated to SQL Server.
- The cache is extremely important to system performance because retrieving
objects from memory is much faster than having to access the disk drive to
find them.
- Be sure to set your scale to 1.0.
Paging File - % Usage Peak - _Total
- A peak amount of paging file usage above 10% generally indicates more
memory is needed.
- An increase in this number normally corresponds to a decrease in the cache hit
ratio.
PhysicalDisk - % Disk Time_Total
- A high percentage of disk time can indicate slow drives or a poor or poorly
configured array that is inadequate for the workload; too little memory on the
server (see Paging File); non-dedicated server configuration; inadequate disk
space; severely fragmented files; better workload distribution required
(separate arrays/drives for data, logs and tempdb); application code
bottlenecks.
Certified Student Course Curriculum - Version 2.0 Page 163
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Monitoring Performance
Monitoring Performance (continued)
2
Additional Disk Performance Counters
The following counters can also be monitored to specifically observe disk
performance. The diskperf -y command must be run at a command prompt and the
server rebooted before adding these counters on Windows 2000 servers only.
PhysicalDisk - Current Disk Queue Length
- A high disk queue length usually indicates a bottleneck at the disks or arrays.
- Set your counter scale to 1.0 for better readability.
PhysicalDisk - Disk Write Bytes/Sec, Disk Read Bytes/Sec
- Monitor these counters to help determine if a disk or array bottleneck is
occurring in read or write operations.
- For example, brief reads and slow writes are usually indicative of a busy
RAID array.
- You would abstract databases, tables, indexes or other objects to resolve the
problem.
Activity
In the following activity, you will select to monitor the disk time percentage
performance on your system.
1. If you are not in SQL Server Management Studio, access it now from the Start
menu > All Programs > Microsoft SQL Server 2008 R2.
2. If prompted to log on to the server, enter your password and click Connect in the
Connect to Server window.
3. Close the Trace Properties window.
4. From the Tools menu, select SQL Server Profiler.
5. In the Performance window, expand the Performance Logs and Alerts node.
6. Right-click Counter Logs and select New Log Settings.
7. In the New Log Settings window, enter Monitor and click
OK.
8. In the window that displays, click Add Counters.
9. At the Performance object drop-down list, select Physical Disk.
10. In the counters list, select %DiskTime. The %DiskTime counter is the percentage
of elapsed time that the selected disk drive is busy servicing read or write
requests.
11. Click Add to add the counter and then click Close to close the Add Counters
window.
12. View the activity in the Performance window.
13. Close the Performance window and the SQL Server Profiler window.
SQL Server Fundamentals Monitoring Activity
Page 164 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Monitoring Activity
2
The Activity Monitor is used to view detailed status of processes and current user
connections.
The Activity Monitor provides a snapshot of what is happening on the server.
Access by clicking the Activity Monitor button on the SQL Server Management
Studio toolbar.
- You can also right-click a server name and select Activity Monitor.
Four graphs display the percentage of processor time, waiting tasks, database I/O,
and batch requests.
The Activity Monitor includes four sections containing the following information:
- Processes: Allows you to view session information (SPIDs). If you right-click
any SPID, the Profiler launches, which will begin a trace on the session in
question.
- Resource Waits: Provides a snapshot of key resource waits taking place on
the server. This helps you identify potential problems on the SQL Server.
- Data File I/O: Allows you to determine if a particular database is being
heavily hit with disk I/O.
- Recent Expensive Queries: Displays the most recent expensive queries (that
are currently in cache). This allows you to identify problem queries.
Click this button to
access the Activity
Monitor.
Certified Student Course Curriculum - Version 2.0 Page 165
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Monitoring Activity
Monitoring Activity (continued)
Steps for Finding Processes that are Causing Blocks
Use the following steps to find processes that are causing blocks or are blocking other
processes.
1. Access SQL Server Management Studio window.
2. On the toolbar, click the Activity Monitor button.
3. Select the Processes section.
4. Process ID 54 has work to perform but has been suspended and blocked. The
Blocked By column for Process ID 54 shows that Process ID 55 is the cause of the
block. Furthermore, the Blocking column for Process ID 55 displays a 1
indicating that Process ID 55 is causing the block.
5. In the SQL Server Management Studio window, click New Query.
6. On the query tab execute an sp_who 54 command to determine the login name
associated with the process.
SQL Server Fundamentals Monitoring Activity
Page 166 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Monitoring Activity (continued)
2
Activity
1. If you are not in SQL Server Management Studio, access it now from the Start
menu > All Programs > Microsoft SQL Server 2008 R2.
2. Make sure you have the Object Explorer pane open (View menu > Object
Explorer).
3. In SQL Server Management Studio, click the Activity Monitor button on the
toolbar.
4. View the information in the processes section. How many processes are currently
running?
_____________________________________________________________
5. Select the Resource Waits section. Are there any waits taking place on the server?
_____________________________________________________________
6. Close the Activity Monitor window.
Certified Student Course Curriculum - Version 2.0 Page 167
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Dynamic Management Views
Dynamic Management Views
2
One powerful feature of SQL Server is dynamic management views (DMV) and
functions (DMF). These objects can be queried to help determine resource
bottlenecks in areas such as cpu utilization, memory, and disk input/output. Dynamic
management views can correlate a particular resource bottleneck with its cause by
identifying object names.
Note: Statistical data retrieved from these dynamic management views are not stored.
If SQL Server is restarted, these statistics are recycled as well.
Dynamic management views are named starting with the prefix 'dm' followed by their
category. Other categories are as follows:
General server dynamic management views:
dm_exec_* - Execution related DMVs
dm_os_* - Operating system related DMVs
dm_io_* - Input/output related DMVs
dm_db_* - Database/objects related DMVs
Component level dynamic management view
sys.dm_clr_* - Common language runtime related DMVs
dm_repl_* - Replication DMVs
dm_broker_* - Service broker DMVs
dm_ftx_* - Full-text search DMVs
dm_qu_* - Query notifications
SQL Server Fundamentals Dynamic Management Views
Page 168 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Dynamic Management Views (continued)
2
DMV Example
The following is an example of a query using a DMV that shows the names of the
stored procedures causing high cpu utilization:












Results:
Certified Student Course Curriculum - Version 2.0 Page 169
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals SQL Server Reports
SQL Server Reports
2
Another powerful feature in SQL Server is SQL Server Reports. There is a set of
canned reports in SQL Server Management Studio that can help gather information in
common areas. There are reports for CPU, memory, disk, sessions, queries,
transactions, and more.
Steps for Viewing SQL Server Reports
1. In SQL Server Management Studio, connect to the server.
2. Expand the Databases node, and then select your database.
3. Right-click the database name and select Reports > Standard Reports. As you can
see, there are many reports available.
SQL Server Fundamentals SQL Server Reports
Page 170 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Reports (continued)
2
4. Select a report and view it in the SQL Server Management Studio interface.
Activity
1. If you are not in SQL Server Management Studio, access it now from the Start
menu > All Programs > Microsoft SQL Server 2008 R2.
2. On the Object Explorer pane, expand the Databases node.
3. Right-click the mas500_app database.
4. Select Reports > Standard Reports > Disk Usage by Table.
5. Take a few minutes to explore the information on the report.
Certified Student Course Curriculum - Version 2.0 Page 171
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Other Performance Management Tools
Other Performance Management Tools
2
In addition to the Microsoft SQL Server Profiler tool available with Microsoft SQL
Server, there are other tools worth mentioning. One such tool, Performance Analysis
for SQL Server developed by Quest Software, can also assist in monitoring and
troubleshooting performance issues. The tool uses a graphical interface to
continuously provide performance status of the SQL Server.
Important: It is recommended that you use Performance Analysis in a test
environment before placing it on a production server.
SQL Server Fundamentals Challenge Questions - Part VI
Page 172 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Challenge Questions - Part VI
2
1. Name a feature in SQL Server that can be used to determine resource bottlenecks
regarding CPU, memory, and disk input/output.
_____________________________________________________________
2. List at least three standard reports that come with SQL Server that show
information for troubleshooting problems.
_____________________________________________________________
_____________________________________________________________
_____________________________________________________________
Certified Student Course Curriculum - Version 2.0 Page 173
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Lab Exercise - Monitoring Performance and Activity
Lab Exercise - Monitoring Performance and Activity
2
1. Access the SQL Server Profiler and create a counter to monitor the Physical and
%Idle Time counters. (page 159).
2. Access the Activity Monitor and determine the following: (page 164)
How many processes are currently running? __________________________
Are there any waits taking place on the server? ________________________
Page 174 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Lesson 10
SQL Server Fundamentals
Backing Up and Restoring Databases
10 2
Most system administrators agree that a clearly defined and consistently executed
backup plan is crucial to the safety of data in the case of application or hardware
failure, physical or electrical disaster, or human error or malicious behavior. In this
lesson, you will learn how to back up, restore, and detach and attach databases in your
system. You will also learn about transferring and copying databases as well as setting
important database options.
The topics in this lesson include:
Backing Up a Database
Restoring a Database
Detaching and Attaching a Database
Transferring and Copying Databases
Setting Database Options and Filegrowth Settings
Certified Student Course Curriculum - Version 2.0 Page 175
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Backing Up a Database
Backing Up a Database
2
You should determine when and how often you back up your systems data. You
should also consider implementing a set schedule where you back up your databases
at regular intervals. This section outlines how to manually back up your data;
however, a backup can be scheduled on a regular basis using maintenance plans. For
more information, see Creating Maintenance Plans on page 195.
Backup and recovery plans should meet the following needs of an organization:
Minimize loss of data
Minimize downtime
Minimize disruptions
Backup Considerations
Unique situations may indicate that its time for a backup. Typically, you should back
up your data any time your system experiences a change in environment. You should
consider both the hardware and software when determining if a backup is needed.
Common milestones include:
Immediately after an installation
Before making any hardware changes
Before importing large amounts of data
Before upgrading any software on your system to new versions or installing new
components or modules
If you expect power failure, such as during bad weather
Before customizing any part of the software
Before closing a period, fiscal year, or Payroll year in Sage ERP MAS 200 SQL
Note: In addition to backing up the databases on the Database Server (SQL Server),
you should copy the entire Sage ERP data folders on the Application Server and store
them in a secure location. Backups on the Database Server and Application Server
should be performed at the same time.
It is also important to note that how and where you handle your backups depends on
the various conditions of each company and situation. How you implement your
backups takes careful consideration and should be addressed with your company and
I.S. group.
SQL Server Fundamentals Backing Up a Database
Page 176 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Backing Up a Database (continued)
2
Types of Backups
There are three main types of backups available in SQL Server:
Full backups: Consists of a complete copy of a database. This type of backup
captures all pages in the database that contain data.
Differential backups: This type of backup captures data that has changed since
the last full backup. The differential backup cannot exist until a full backup is
performed.
Transaction Log backups: Copies all the log records that have been written to
the transaction log since the last full backup or transaction log backup. A Full
backup is required in order to create a Transaction Log backup.
The needs of your client will help determine which backup method to use.
If backups are needed once a day, a full backup in the evening will solve this
issue.
If multiple backups during the day are needed, you could do one full backup in the
middle of the night and differential backups or transaction log backups throughout
the day.
It is also important to know when the tape backup will occur.
A preferred backup method is to back up your Sage ERP MAS 200 SQL
databases to a local drive and then back up the files created by SQL Server. You
would then have two backup copies of the data.
Scheduling Database Backups
You can also schedule a backup using the Maintenance Plans option in SQL Server
Management Studio Options. Consider implementing a set schedule to back up your
databases at regular intervals. If your hardware fails, you can recover with a minimum
of data loss. For more information, see Creating Maintenance Plans on page 195.
The backup strategy for different each company is unique. You should consider
beginning with daily backups, then adjust as needed based on your particular
companys needs.
Certified Student Course Curriculum - Version 2.0 Page 177
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Backing Up a Database
Backing Up a Database (continued)
2
Steps for Performing a Database Backup
1. In SQL Server Management Studio, locate and right-click the database you want
to back up.
SQL Server Fundamentals Backing Up a Database
Page 178 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Backing Up a Database (continued)
2
2. From the Tasks menu, select Backup.
Use the General page to select the type of backup and destination.
It is recommended that you perform a Full backup initially.
- Every company must carefully weigh the factors unique to their environment
when creating backups.
Be sure to use the database name in the file name entered for the backup.
If you are changing the recovery model, perform a Full backup, restart your SQL
Server, and then rebuild the indexes.
The Transaction Log is available only if the recovery model is set to Bulk-logged
or Full.
Click this button to
specify the backup
location and file
name.
Choose the type of
backup you want to
perform: Full or
Differential.
Select this check box
if you are creating a
copy of a database.
For example, you
could create a copy of
the production
database for testing
purposes.
Certified Student Course Curriculum - Version 2.0 Page 179
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Backing Up a Database
Backing Up a Database (continued)
2
3. After defining the information on the General page, select Options under the
Select a page section.
4. Ensure the Back up to the existing media set check box is selected.
5. Select the Overwrite all existing backup sets check box.
6. In the Reliability section, select the Verify backup when finished check box. This
ensures you will be notified when the backup is complete.
7. In the Compression section, select Compress backup from the Set backup
compression drop-down.
Note: Creating compressed backups is supported only in SQL Server 2008
Enterprise and later; however, beginning in SQL Server 2008, every edition can
restore a compressed backup.
A compressed backup is smaller than an uncompressed backup of the same data,
compressing a backup typically requires less device I/O and usually increases
backup speed significantly.
SQL Server Fundamentals Backing Up a Database
Page 180 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Backing Up a Database (continued)
2
8. Click OK to start the backup process. A progress bar displays as the system backs
up the database with the file name entered. It will then verify the integrity of the
backup and display a message that the backup was completed successfully.
9. Click OK when prompted that the database was backed up successfully.
Activity
Use the following steps to back up a database.
1. If you are not in SQL Server Management Studio, access it now from the Start
menu > All Programs > Microsoft SQL Server 2008 R2.
2. In the Object Explorer (View menu > Object Explorer), expand the Sage_SQL
node and then expand the Databases node.
3. Right-click the mas500_app database and then select Tasks > Backup.
4. At the Backup type field, select Full.
5. Select the following as the destination for the backup:
C:\Program Files\Microsoft SQL Server\MSSQLSERVER\MSSQL\Backup
6. Select Options under the Select a page section.
7. Select the Verify backup when finished check box.
8. Click OK to start the backup.
9. Click OK when the "completed successfully" message displays.
10. In Windows Explorer, verify that the backup file was saved to the destination
location indicated. The backup file will have a .bak file extension.
Certified Student Course Curriculum - Version 2.0 Page 181
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Restoring a Database
Restoring a Database
2
After creating a backup, you can restore it. The Restore Database window allows you
to define information about the destination and source databases for the restore
process.
Steps for Restoring a Database
1. From the Microsoft SQL Server 2008 program group, select SQL Server
Management Studio.
2. In the Object Explorer pane, expand the node for your server and then expand the
Databases node.
3. Locate and right-click the database you want to restore.
You can choose Database if the backup occurred on the same server. You are
then provided with a list of backups that have been performed on this server.
SQL Server Fundamentals Restoring a Database
Page 182 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Restoring a Database (continued)
2
4. From the right-click menu, select Tasks > Restore > Database.
If restoring a database over an existing one, select the database you want to
restore over from the To database drop-down.
If you are bringing in a database from an outside source, select From Device.
5. The name of the database you are restoring displays in the To database drop-
down. To create a new database, you can enter its name.
Select this option and
then the ellipsis
button to specify the
backup media and
location for your
restoration process.
Certified Student Course Curriculum - Version 2.0 Page 183
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Restoring a Database
Restoring a Database (continued)
2
6. In the Source for restore section, select the From Device option and click the
ellipsis button to specify a backup that was saved previously.
7. Click Add.
8. Select the backup file and click OK.
9. On the General page, select the Restore check box for the backup set being
restored.
10. Scroll to the right to review the database file components.
Click Add to locate
the file.
SQL Server Fundamentals Restoring a Database
Page 184 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Restoring a Database (continued)
2
11. Under the Select a page pane, select Options.
12. In the Recovery state section, select the Leave the database ready to use... option
selected.
Note: This is the default option and is equivalent to specifying WITH
RECOVERY in a RESTORE statement (T-SQL). Under the Full recovery model,
or Bulk-Logged recovery model, select this option only if you are restoring all the
log files now.
Activity
Use the following activity to restore the database you backed up in the previous
activity.
1. If you are not in SQL Server Management Studio, access it now from the Start
menu > All Programs > Microsoft SQL Server 2008 R2.
2. In the Object Explorer (View menu > Object Explorer), expand the Sage_SQL
node and then expand the Databases node.
3. Right-click the mas500_app database and then select Tasks > Restore >
Database.
4. At the To Database field, select the mas500_app database.
5. Select the From device option and click the ellipsis button.
6. Click Add to locate the mas500_app.bak file and click OK.
7. In the Specify Backup window, click OK.
8. In the "Select the backup sets to restore" section, select the Restore check box.
9. In the Recovery state section, select the Leave the database ready to use... option.
10. Click OK.
11. When prompted with the "completed successfully" message, click OK.
Use the ellipsis button
to change the
database file (.mdf)
path.
Certified Student Course Curriculum - Version 2.0 Page 185
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Detaching and Attaching a Database
Detaching and Attaching a Database
2
As an alternative to backup and restore of databases onto another server or drive, you
can detach a database from one server and attach it to another. A detached database
cannot be used until it is attached re-attached.
When you detach a database, it leaves the .mdf and .ldf files intact in the SQL Data
directory, but removes it from the list of databases with SQL Server Management
Studio.
This process can be quicker than running a backup and restore process.
You can also have a copy of the original .mdf and .ldf files with demo data, which can
easily be re-attached for a quick refresh of the data.
Note: Before detaching a database, verify there are no Sage ERP MAS 500 users
connected to the databases.
Important: If using a recovery method of Full or Bulk Logged, be sure to create a
backup prior to detaching.
Steps for Detaching and Attaching Databases
1. In SQL Server Management Studio, right-click the database, and then select Tasks
> Detach.
Review the information in the window for any connections before detaching the
database.
SQL Server Fundamentals Detaching and Attaching a Database
Page 186 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Detaching and Attaching a Database (continued)
2
2. Click OK to detach the database, and then click OK again at the confirmation
message.
3. To attach the database, right-click the Databases node, and then select Tasks >
Attach.
All of the respective files should reside in the same directory location. If not,
select the .mdf file, and modify the paths accordingly for the .ldf and .ndf
files.
4. Click Add. The Locate Database Files window appears. Select the .mdf file from
the Program Files\Microsoft SQL Server\MSSQL\Data directory that relates to
your detached database.
5. Click OK to attach the database, and then click OK again at the confirmation
message.
Certified Student Course Curriculum - Version 2.0 Page 187
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Transferring and Copying Databases
Transferring and Copying Databases
2
At times, you may find it useful to copy an existing set of Sage ERP databases to
create a new set of databases on the same SQL Server or on a different SQL Server.
For example, you might decide to create a copy of your existing production
databases in order to create an environment in which you can safely test new
upgrades, perform customizations, use for training purposes etc.
Considerations When Creating a New Set of Databases on the Same
Server
Sage ERP users of the same name in both sets of databases share a logon.
If a copy of the databases is made on the same SQL Server, be aware that you will
be limited in your ability to change existing Sage
User information in either set of databases.
For existing users that are copied from one set of databases to the other, the
passwords cannot be changed and do not change the Application Role function in
Maintain Users.
New users created in one database set will not have access to any other database
set information.
For users to have access to data in the other databases, they must be created within
the appropriate database set.
No password should be defined for users that will have access to multiple
database sets.
It is recommended that you create unique logins for each set of databases on the
same server.
If you are using Windows NT authentication, changing user information does not
apply.
SQL Server Fundamentals Setting Database Options and Filegrowth Settings
Page 188 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Setting Database Options and Filegrowth Settings
2
Setting Database Options and Filegrowth Settings
One of the most important properties you can manage within your databases are size
and growth properties of files. As more data is stored in the database, you will need to
manage the size and growth of these files. One property that you can define is the
Autogrowth property of a file. Autogrowth allows you to control how the file will
expand after the maximum file limit is reached. In this section, you will learn how to
set this property along with other database options.
For the following example, a new database was created by a team that developed the
WeSeller application (an in-house application). A technical audit has highlighted that
inappropriate database options were specified. The following section will show you
how to set the correct database options to ensure the company meets its standards:
Full Recovery Model
Autoclose disabled
Autoshrink disabled
Database compatibility level is set to 100
File growth is set to 10 MB on both the data and log files.
Steps for Setting Database Options
1. In SQL Server Management Studio, right-click the database and then select
Properties.
Certified Student Course Curriculum - Version 2.0 Page 189
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Setting Database Options and Filegrowth Settings
Setting Database Options and Filegrowth Settings (continued)
2
2. Select Files under the Select a page section.
3. In the Database files section, select the Autogrowth field in a row and click the
ellipsis button to change the autogrowth setting.
4. In the Change Autogrowth window that displays, select whether to define the file
growth by percent or megabytes.
5. You can also select for restricted or unrestricted file growth.
6. Click OK.
7. In the Database files pane, you can also change the value at the Initial Size field
for a row.
8. Select Options under the Select a page section.
SQL Server Fundamentals Setting Database Options and Filegrowth Settings
Page 190 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Setting Database Options and Filegrowth Settings (continued)
2
Several database-level options that determine the characteristics of the database
can be set for each database.
- These options are unique to each database and do not affect other databases.
When the Auto Close option is enabled, the database is shut down cleanly and its
resources are freed after the last user exits. The database automatically reopens
when a user tries to use the database again. When set to disabled, the database
remains open after the last user exits
When the Auto Shrink option is enabled, the database files are candidates for
periodic shrinking. Both data file and log files can be shrunk automatically by
SQL Server. AUTO_SHRINK reduces the size of the transaction log only if the
database is set to SIMPLE recovery model or if the log is backed up. When
disabled, database files are not automatically shrunk during periodic checks for
unused space.
9. On the Options page, make sure SQL Server 2008 (100) is selected.
10. At the Recovery model field determine which recovery model to use.
Note: Under the Full recovery model, if transactions have been marked in each of
the related databases, you can recover the database to a consistent point. This
requires restoring each of the databases with the same transaction mark as the
recovery point for each. However, using a mark for a recovery point loses any
transactions committed after that point.
Certified Student Course Curriculum - Version 2.0 Page 191
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Setting Database Options and Filegrowth Settings
Setting Database Options and Filegrowth Settings (continued)
2
Activity
In this activity, you will
1. If you are not in SQL Server Management Studio, access it now from the Start
menu > All Programs > Microsoft SQL Server 2008 R2.
2. In the Object Explorer (View menu > Object Explorer), expand the Sage_SQL
node and then expand the Databases node.
3. Right-click the mas500_app database and then select Properties.
4. Select Files under the Select a page section.
5. In the Database files section, in the first row, click the ellipses button at the
Autogrowth field.
6. In the Change Autogrowth for mas500_app window that displays, make sure the
In Megabytes option is selected and type .
7. Click OK.
8. Repeat these same autogrowth steps for the second row.
9. Change the value at the Initial Size field for the first row to and for the
second row.
10. Select Options under the Select a page section.
11. At the Recovery model field, select Full.
12. Make sure the value at the Compatibility level field is set to SQL Server 2008
(100).
13. At the Auto Close and Auto Shrink fields, make sure False is selected.
SQL Server Fundamentals Challenge Questions - Part VII
Page 192 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Challenge Questions - Part VII
2
1. What are the three types of backups you can perform in SQL Server?
_____________________________________________________
_____________________________________________________
_____________________________________________________
2. What is an alternative to backing up and restoring a database?
_____________________________________________________
Certified Student Course Curriculum - Version 2.0 Page 193
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Lab Exercise - Creating a Backup and Restore
Lab Exercise - Creating a Backup and Restore
2
1. Create a backup of the mas500_app database using the Full backup type.
(page 175)
2. Make to verify when the backup is finished.
3. Restore the backup you created using the "Leave the database ready to use..."
option. (page 181)
Page 194 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Lesson 11
SQL Server Fundamentals
Working with Maintenance Plans
11 2
Maintenance plans allow you to automate tasks for maintaining your database.
The topics in this lesson include:
Creating Maintenance Plans
Certified Student Course Curriculum - Version 2.0 Page 195
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Creating Maintenance Plans
Creating Maintenance Plans
2
Maintenance plans create a workflow of the tasks required to make sure that your
database is optimized, is regularly backed up, and is free of inconsistencies. The
Maintenance Plan wizard creates core maintenance plans; however, you can also
manually create plans.
Note: Maintenance plans only run against databases set to compatibility level 80 or
higher.
Note: The user login account must be a member of the sysadmin role to create and
manage maintenance plans, and to view them in Object Explorer.
Some of the tasks that can be performed in Maintenance Plans include:
Checking for data consistency: This task performs an internal consistency check
of the data and index pages within the database.
Shrinking a database: This task allows you to remove unused pages in the
database. This reduces disk space that can be returned to the operating system or
used for future growth.
Updating statistics: This task provides a way to update the statistics generated in
the database engine. Having up-to-date statistics means the SQL Server will take
the correct path to the data, which means index scans and table scans will be more
accurate.
Cleaning up history: This task deletes the historical data related to database
backups and restorations as well as Maintenance Plan activity.
Executing SQL Server Agent jobs: Allows you to select SQL Server Agent jobs
to run as part of the maintenance plan.
Backing up databases (Full, Differential, or Transaction Log): Allows you to
specify source databases, destination files or tapes, and overwrite options for the
backup type.
Re-building and reorganizing indexes: This task reorganizes data on the data
and index pages and also optimizes the distribution of data and free space on the
index pages. This allows for future faster growth.
Steps for Creating a Maintenance Plan
In the following steps, you will learn how to create a maintenance plan that backs up
the database, performs a consistency check, and rebuilds the indexes.
1. From the Microsoft SQL Server 2008 program group, select SQL Server
Management Options.
SQL Server Fundamentals Creating Maintenance Plans
Page 196 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Creating Maintenance Plans (continued)
2
2. Access the SQL Server Maintenance Plan Wizard by expanding the Management
node in SQL Server Management Options > right-clicking Maintenance Plans >
selecting Maintenance Plan Wizard.
3. In the SQL Server Maintenance Plan Wizard page that displays, click Next.
You can choose to
create a schedule for
all tasks or separate
schedules for each
task.
Certified Student Course Curriculum - Version 2.0 Page 197
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Creating Maintenance Plans
Creating Maintenance Plans (continued)
2
4. In the Select Plan Properties wizard page, enter a name for your plan and a
description.
5. You can choose to select whether to schedule each task individually or together.
In our example, we will select the "Single schedule for the entire plan or no
schedule" option to schedule all the tasks together.
6. Click Change. In the Job Schedule Properties window that displays, set the time,
frequency, and duration for performing the consistency checks on the databases.
In our example, we will enter Daily at the Occurs drop-down, and type 10:00 pm
for the time.
Use the Change button to set the time, frequency, and duration for performing the
consistency checks on the databases.
SQL Server Fundamentals Creating Maintenance Plans
Page 198 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Creating Maintenance Plans (continued)
2
7. Click Next.
8. Select the tasks you want to perform and click Next.
The Select Maintenance Task Order window allows you to determine the order in
which to perform the tasks.
Certified Student Course Curriculum - Version 2.0 Page 199
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Creating Maintenance Plans
Creating Maintenance Plans (continued)
2
9. Click Next.
10. For each task, select whether to include all databases or one or more databases at
the Databases drop-down and define any other options for the task as needed.
You can change the
folder location by
clicking the ellipsis
button.
SQL Server Fundamentals Creating Maintenance Plans
Page 200 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Creating Maintenance Plans (continued)
2
11. Click Next in each task window.
12. Click Next.
13. In the Complete the Wizard window, verify your choices and click Finish.
You can change the
folder location by
clicking the ellipsis
button.
Certified Student Course Curriculum - Version 2.0 Page 201
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Creating Maintenance Plans
Creating Maintenance Plans (continued)
2
14. In the Maintenance Plan Wizard page, after processing is complete, click Close.
15. In SQL Server Management Studio, on the Object Explorer pane, expand the
Management node and then the Maintenance Plans node. Notice the new
maintenance plan.
16. You can also view the plan under the SQL Server Agent node. Expand the SQL
Server Agent node and then expand the Jobs node.
SQL Server Fundamentals Creating Maintenance Plans
Page 202 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Creating Maintenance Plans (continued)
2
Activity
In the following activity, you will create a maintenance plan that checks for database
integrity, rebuild indexes, and create a full backup on a daily basis.
1. If you are not in SQL Server Management Options, access it now from the
Microsoft SQL Server 2008 program group.
2. Access the SQL Server Maintenance Plan Wizard by expanding the Management
node in SQL Server Management Options > right-clicking Maintenance Plans >
selecting Maintenance Plan Wizard.
3. On the Welcome page, click Next.
4. On the Select Plan Properties page, type at the
Name field.
5. Type the following description:

6. Make sure the Single schedule for the entire plan or no schedule option is selected
and click Change.
7. At the Occurs field, select Daily.
8. At the Occurs once at field, enter .
9. Click Next.
10. On the Select Maintenance Tasks page, select the Check Database Integrity,
Rebuild Index, and Back Up Database (Full) check boxes are selected and click
Next.
11. On the Select Maintenance Task Order page, keep the order of the tasks as is and
click Next.
12. On the Define Database Check Integrity Task page, at the Databases drop-down,
select All databases, and click OK. Click Next.
13. On the Define Rebuild Index Task page, at the Database drop-down, select All
databases, and click OK.
14. On the Define Back Up Database (Full) Task page, at the Databases drop-down,
select All databases, and click OK.
15. Make sure the Create a backup file for every database option is selected, and click
Next.
Certified Student Course Curriculum - Version 2.0 Page 203
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Creating Maintenance Plans
Creating Maintenance Plans (continued)
2
2
16. On the Select Reports Options page, click Next.
17. On the Complete the Wizard page, click Finish.
18. On the Maintenance Plan Wizard Progress page, click Close.
19. In SQL Server Management Studio, on the Object Explorer pane, expand the
Management node and then expand the Maintenance Plans node to view your new
maintenance plan.
Certified Student Course Curriculum - Version 2.0 Page 204
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Challenge Questions - Part VIII
Challenge Questions - Part VIII
2
1. List at least three tasks that you can include in a maintenance plan.
_________________________________________________________
_________________________________________________________
_________________________________________________________
2. After creating your maintenance plan, which two places can you view it from in
SQL Server Management Studio?
_________________________________________________________
_________________________________________________________
Certified Student Course Curriculum - Version 2.0 Page 205
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Lab Exercise - Creating a Maintenance Plan
Lab Exercise - Creating a Maintenance Plan
2
1. In SQL Server Management Options, create a plan to reorganize and rebuild the
indexes and backup all the databases using the Full method. (page 195)
2. Perform the tasks on all databases.
3. Schedule all the tasks to occur daily at 4:00 am. (page 199)
4. After creating the plan, view it under the Maintenance Plan node in SQL Server
Management Studio. (page 201)
Page 206 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Lesson 12
SQL Server Fundamentals
Understanding SQL Server Integration Services
12 2
SQL Server Integration Services integrates information from various data sources. It
allows you to go beyond just moving data around by using Extract, Transform, and
Load (ETL) to create applications that manage databases and system resources, for
example.
The topics in this lesson include:
Overview of SQL Server Integration Services
Developing Packages Using SSIS
Certified Student Course Curriculum - Version 2.0 Page 207
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Overview of SQL Server Integration Services
Overview of SQL Server Integration Services
2
SQL Server Integration Services, also known as SSIS, provides the ability to
transform data into meaningful and actionable information. SQL Server Integration
Services satisfies the traditional demands of Extract, Transform, and Load (ETL)
operations and general-purpose data integration. It also provides a robust, flexible,
scalable, and extensible architecture.
Challenges
Some challenges include:
Retrieve and merge data from multiple sources.
Cleanse and transform the data.
Load the data into appropriate data stores for analysis and reporting.
Enterprises spend 60 to 80% of their resources in the data-integration stage. With
SSIS, you can import and export data from relational databases.
Business Scenarios
The different business scenarios for using SSIS are:
Importing and exporting data from relational databases.
Populating data warehouses (ETL).
Cleaning and standardizing data.
Merging data from heterogeneous data stores.
Automating administrative tasks.
About SSIS Packages
A package in SSIS is the basic unit of work, deployment, and execution. It can be
designed graphically or built programmatically and is saved in XML format to the file
system or SQL Server. An SSIS package is an organized collection consisting of:
Connection managers: Logical representation that is stored in the package and
cannot be shared between packages.
Control flow components: Is a process-oriented workflow engine. A package
consists of a single control flow. Control flow elements are: containers, tasks,
precedence constraints, and variables. Control flow allows you to execute and
build packages and data flows programmatically. You can also develop custom
tasks and extend process functionality with a Script Task. Custom tasks and
transformations can be packaged and can include a user interface.
Data flow components: Encapsulates the data flow engine.
SQL Server Fundamentals Overview of SQL Server Integration Services
Page 208 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Overview of SQL Server Integration Services (continued)
2
Event handlers: Event handlers respond to events raised during package
execution and have the same structure as a package, including control flow and
data flow. Examples include:
- Send an email when a warning or error occurs.
- Retrieve system information when a package runs.
- Clean up temporary data storage when a package completes.
Log Providers
You can implement logging in packages, containers, and tasks. You can also capture
runtime information about a package for auditing and troubleshooting after each
execution. Examples include:
Log warning or error events.
Log operator name and package execution time.
Configurations
Multiple configurations are possible per package. You can also have shared
configurations across packages. Configurations of SSIS packages include:
Dynamic initialization of a package
Variety of configuration sources, such as:
- SQL
- XML
- Registry
- Environment variable
- Parent package
Deployment Tools
The following are deployment tools that can be used with SSIS packages:
Deployment Utility: This utility assembles all packages in a project for
installation on a different server. This includes all related files in the project, such
as configuration files or documentation.
Package Installation Wizard: This wizard guides you through the steps to install
packages. This allows you to make configuration changes during the installation
and deploy packages to the server file system or SQL Servers msdb database.
Certified Student Course Curriculum - Version 2.0 Page 209
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Developing Packages Using SSIS
Developing Packages Using SSIS
2
The first step when developing packages is to create the Integration Services project.
In set of steps below, you will learn how to develop a package that exports data ready
for import into an external system. In the second set of steps, you will automate the
execution of this package on a schedule.
Steps for Creating an Integration Services Project
1. From the Start menu, select All Programs > Microsoft SQL Server 2008 > SQL
Server Business Intelligence Development Studio.
SQL Server Fundamentals Developing Packages Using SSIS
Page 210 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Developing Packages Using SSIS (continued)
2
2. From the File menu, select New > Project.
3. In the Projects types pane, ensure Business Intelligence Projects is selected.
4. In the Templates pane, select Integration Services Project.
5. Type a name for the project, such as CustomerCreditExtract.
6. In the Location field, enter C:\Applications and click OK.
Certified Student Course Curriculum - Version 2.0 Page 211
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Developing Packages Using SSIS
Developing Packages Using SSIS (continued)
2
Steps for Developing the Package
The following steps will show you how to develop a package that exports data into an
external system.
1. From the File menu, select Save Package.dtsx As and rename the file to
something meaningful.
2. When prompted to rename the package object, click Yes.
3. From the View menu, select Toolbox.
SQL Server Fundamentals Developing Packages Using SSIS
Page 212 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Developing Packages Using SSIS (continued)
2
4. When the Toolbox appears, click the pin icon to make it stay visible as shown
below:
5. To provide more screen real-estate, unpin both the Solution Explorer and
Properties windows if they are visible.
To archive any existing export files before creating a new export file
In our example, there is a folder called C:\Applications\CreditManagement\Import
associated with the CreditManagement application. Each day at 4:00 am, details of
Customers' credit limits need to be exported from the mas500_app database into a file
in that folder. Before exporting the data, we need to move any existing files in the
folder to the C:\Applications\CreditManagement\Archive folder to avoid overwriting
them.
6. Right-click in the center of the control flow design surface and click Variables
7. In the Variables window, click the Add Variable icon:
8. For the Name of the variable, enter FileName. Scroll to the right of the window
and in the Data Type column, choose String.
9. Add another variable called NewFileName and also make it a String.
Note: Variable and object names in SSIS are case-sensitive.
Certified Student Course Curriculum - Version 2.0 Page 213
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Developing Packages Using SSIS
Developing Packages Using SSIS (continued)
2
10. Click the Toolbox tab, under the heading Control Flow Items, click the Foreach
Loop Container and drag it to the Control Flow area of the package.
11. Right-click the Foreach Loop Container and click Edit.
12. In the Foreach Loop Editor dialog window, click Collection property page.
13. In the Foreach Loop Editor window, enter the properties as shown in the
following table:
Property Value
Enumerator Foreach File Enumerator (even though this may already
be shown, re-select it to bring up the enumerator
configuration)
SQL Server Fundamentals Developing Packages Using SSIS
Page 214 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Developing Packages Using SSIS (continued)
2
14. In the Enumerator configuration section, enter the properties as shown in the
following table:
15. In the Foreach Loop Editor dialog window, click Variable Mappings property
page and enter the properties as shown in the following table:
Note: The variable mapping will take the fully qualified name of the file (which
includes the path, name, and extension of the file) and update the value of the variable
for every loop of the package.
16. Right-click the Foreach Loop Container and click Rename. Make the new name
of the container For Each Existing File.
17. Click OK to Save the changes.
18. From the Toolbox, drag a Script Task inside the For Each Existing File container.
Property Value
Folder \\SQLTRAIN\Applications\CreditManagement\Import
Property Value
Variable User:: FileName
Index 0
Certified Student Course Curriculum - Version 2.0 Page 215
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Developing Packages Using SSIS
Developing Packages Using SSIS (continued)
2
19. Right-click the Script Task and select Rename. Make the new name Calculate
Output Filename
20. Right-click the Calculate Output Filename task and click Edit.
21. In the ScriptLanguage drop-down, select Microsoft Visual Basic 2008.
22. Click in the value area for the ReadOnlyVariables and click the Ellipsis that
appears.
23. In the Select Variables dialog, tick the box beside User::FileName and click OK.
24. Click in the value area for the ReadWriteVariables and click the Ellipsis that
appears.
25. In the Select Variables window, select the check box beside User::NewFileName
and click OK.
26. Click the Edit Script button.
27. Scroll to the bottom of the code and add the following code (in one line) in the
location shown:
Note: this expression can be copied and pasted from the file
C:\Temp\Lab7Snippets.txt
SQL Server Fundamentals Developing Packages Using SSIS
Page 216 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Developing Packages Using SSIS (continued)
2
28. From the ssisscript - Integration Services Script Task dialog, choose Exit from the
File menu.
29. In the Script Task Editor, click OK.
30. From the Toolbox, drag a File System Task inside the For Each Existing File
container under the Calculate Output Filename task.
31. Click on the Calculate Output Filename task and drag the green precedence
constraint arrow down onto the new File System Task.
32. Right-click the File System Task and select Rename. Make the new name Rename
Existing File.
33. Right-click the Rename Existing File task and select Edit.
34. Choose the following options and then click OK.
35. Right-click the Rename Existing File task, then choose Properties.
36. From the Properties toolbox, set DelayValidation to True.
37. From the File menu, click Save All.
Note: We have created a task to rename any existing file to the same name with the
date appended to the end of it. The file being renamed is coming from the variable
FileName and the destination name is in the NewFileName variable.
Certified Student Course Curriculum - Version 2.0 Page 217
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Developing Packages Using SSIS
Developing Packages Using SSIS (continued)
2
Test initial functionality to make sure it works
38. Open Windows Explorer and navigate to the folder
C:\Applications\CreditManagement\Import.
39. In the right-hand pane, right-click the empty space and choose New then Text
Document.
40. Rename the document to TestDocument_1.txt.
41. In the right-hand pane, right-click the empty space and choose New then Text
Document.
42. Rename the document to TestDocument_2.txt.
43. Return to the Visual Studio window. From the Debug menu, choose Start
Debugging.
44. The package should execute and all tasks should be green when complete.
SQL Server Fundamentals Developing Packages Using SSIS
Page 218 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Developing Packages Using SSIS (continued)
2
45. In Windows Explorer, note that the filenames have now been changed by
appending today's date to them in the format YYYYMMDD.
46. From the Debug menu click Stop Debugging.
Add a task to move the renamed files to a new folder
47. From the Toolbox, drag another File System Task inside the For Each Existing
File container. Rename it to Move File.
48. Click on the Rename Existing File task and drag a green precedence constraint
down onto the new Move File task.
49. Right-click the Move File task and click Edit.
Certified Student Course Curriculum - Version 2.0 Page 219
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Developing Packages Using SSIS
Developing Packages Using SSIS (continued)
2
50. Configure the settings as follows:
51. Click in the value area for the Destination Connection property and click the
down-arrow.
52. From the drop-down list, choose the option to create a New Connection.
53. Configure the File Connection Manager Editor as follows:
54. The folder name is:
\SQLTRAIN\Applications\CreditManagement\Archive
55. Click OK.
56. Click OK to close the File System Task Editor window.
57. Right-click the Move File task and choose Properties.
58. From the Properties toolbox, set DelayValidation to True.
59. From the File menu, click Save All.
60. Test the application.
61. From the Debug menu, click Start Debugging.
SQL Server Fundamentals Developing Packages Using SSIS
Page 220 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Developing Packages Using SSIS (continued)
2
62. The program should run to completion:
63. From the Debug menu, click Stop Debugging.
64. In Windows Explorer ensure that the files have been moved to the Archive folder:
65. In Visual Studio, drag a Data Flow task from the Toolbox onto the Control Flow
under (not in) the For Each Existing File container and rename it to Export Credit
Details.
66. Click the For Each Existing File container and drag a green precedence constraint
arrow down onto the new Export Credit Details task.
67. Right-click the Export Credit Details task and choose Edit.
68. In the Data Flow Editor, drag an ADO.NET Source onto the surface and rename it
to mas500_app Credit.
69. Right-click the mas500_app Credit data source and click Edit.
70. Click the New button to create a new connection manager.
71. In the Configure ADO.NET Connection Manager dialog, click New.
72. In the Connection Manager window, type the server name as SQLTRAIN.
73. From the Select or enter a database name drop-down, select mas500_app and
click OK.
Certified Student Course Curriculum - Version 2.0 Page 221
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Developing Packages Using SSIS
Developing Packages Using SSIS (continued)
2
74. Click OK to close the Configure ADO.NET Connection Manager window.
75. In the ADO.NET Source Editor dialog, from the Data access mode drop down,
select SQL Command.
76. In the SQL Command Text section, type the following query:
77. Click the Preview button to preview the data then Close to close the preview
window. (Customer data should appear.)
78. Click OK to close the ADO.NET Source Editor.
79. From the toolbox, drag a Flat File Destination component onto the design surface
under the mas500_app Credit data source and rename it to Credit File.
80. Drag a green data connector from the data source (mas500_app Credit) to
destination (Credit File).
81. Right-click the Credit File destination and click Edit.
82. In the Flat File Destination Editor dialog, click New to create a new flat file
connection manager.
83. In the Flat File Format window, select Delimited and click OK.
SQL Server Fundamentals Developing Packages Using SSIS
Page 222 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Developing Packages Using SSIS (continued)
2
84. In the Flat File Connection Manager Editor, configure the screen as follows:
Note that the file name is:
\\SQLTRAIN\Applications\CreditManagement\Import\CreditDetails.txt
85. Click OK to close the window.
86. In the Flat File Destination Editor window, click on the Mappings pane then click
OK.
87. From the File menu, select Save All.
88. Test our package again.
89. From the Debug menu, click Start Debugging .
90. The program should run to completion and 69 rows should be transferred.
91. From the Debug menu, click Stop Debugging.
Certified Student Course Curriculum - Version 2.0 Page 223
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Developing Packages Using SSIS
Developing Packages Using SSIS (continued)
2
92. In Windows Explorer note that a new CreditDetails.text file has been created in
the Import folder.
93. In Visual Studio, from the Debug menu, click Start Debugging.
94. Again the program should run to completion. Then form the Debug menu, select
Stop Debugging.
95. Now verify in Windows Explorer that the last file generated was in fact archived
to the Archive folder before another file was created.
Steps for Deploying and Scheduling Execution of the Package
1. First we will select an option to request a deployment utility that will let us easily
deploy the package. Then we will enable configurations for the package. This will
help greatly if we ever need to change the paths to files or use a different database
server.
2. From the Project menu, select CustomerCreditExtract Properties
3. In the CustomerCreditExtract Property Pages dialog, click on the Deployment
Utility pane.
SQL Server Fundamentals Developing Packages Using SSIS
Page 224 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Developing Packages Using SSIS (continued)
2
4. Configure the properties as shown:
5. Click OK to close the dialog.
6. Click the Control Flow tab, from the SSIS menu, click Package Configurations.
7. In the Package Configurations Organizer check the box to Enable package
configurations.
8. Click the Add button.
9. In the Package Configuration Wizard window, click Next.
10. In the Select Configuration Type window, enter the filename as
\\SQLTRAIN\Applications\CreditManagement\ExtractCustomerCredit.dtsconfig
and click Next.
11. In the Objects list, check the three Connection Managers:
12. Click Next.
13. In the Completing the Wizard window, enter the Configuration name as
ExtractCustomerCredit Configuration and click Finish.
14. In the Package Configurations Organizer window, click Close.
15. From the File menu, click Save All.
16. Build our package so it is ready for deployment.
17. From the Build menu, click Build CustomerCreditExtract.
Certified Student Course Curriculum - Version 2.0 Page 225
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Developing Packages Using SSIS
Developing Packages Using SSIS (continued)
2
Deploy the package
18. In Windows Explorer, navigate to C:\Temp.
19. Right-click the file CustomerCreditExtract.SSISDeploymentManifest and click
Deploy.
20. In the Welcome to the Package Installation Wizard window, click Next.
21. In the Deploy SSIS Packages window, choose SQL Server deployment and click
Next.
22. In the Server Name text box, type SQLTRAIN.
23. In the Package Path text box type a forward slash /.
24. Click Next.
25. In the Select Installation Folder window, click Next.
26. In the Confirm Installation window, click Next.
27. In the Configure Packages window, click Next.
28. When the package has deployed, click Finish.
Schedule the package for execution
29. If it is not already open, open SQL Server Management Studio and connect to the
SQLTRAIN database engine.
30. On the Object Explorer pane, expand the SQL Server Agent node.
31. Right-click Jobs and click New Job.
32. In the New Job window, set the Name textbox to Extract Customer Credit Details
then click on the Steps pane.
33. Click New to add a new job step.
34. In the New Job Step window, set the Step name to Extract and the Type to SQL
Server Integration Services Package.
35. In the Server dropdown on the General tab, type SQLTRAIN.
36. Click the Ellipsis to the right of the Package textbox and from the popup, select
the Extract package and click OK.
37. Click OK to close the New Job Step window.
38. In the New Job window, click the Schedules pane then the New button to create a
new job schedule.
SQL Server Fundamentals Developing Packages Using SSIS
Page 226 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Developing Packages Using SSIS (continued)
2
39. Configure the job as follows:
40. Click OK to save the schedule.
41. In the New Job window, click OK to save the job. We have now created and
scheduled our job. The final task is to test that it runs ok from within SQL Server.
42. In Object Explorer expand the Jobs node.
43. Right-click the Extract Customer Credit Details job and select Start Job At Step.
44. The job should now run successfully.
The package is now scheduled.
Certified Student Course Curriculum - Version 2.0 Page 227
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Challenge Questions - Part IX
Challenge Questions - Part IX
2
1. List at least one business case for using SQL Server Integration Services.
_______________________________________________________
2. Which two deployment tools can be used with SSIS packages?
_______________________________________________________
_______________________________________________________
Page 228 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Lesson 13
SQL Server Fundamentals
Disaster Recovery
13 2
A disaster recovery plan should define which databases and files should be backed up
on a regular basis. The plan should also determine where and how those files should
be protected.
The topics in this lesson include:
Planning for Disaster Recovery
High Availability Options
Certified Student Course Curriculum - Version 2.0 Page 229
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Planning for Disaster Recovery
Planning for Disaster Recovery
2
With disaster recovery, it is important to note that every company should adopt the
method that works best for their needs. For example, one company may save backups
on tape and ship them off-site to another location. Another company may use an
online backup service to store their backups. No two disaster recovery plans are alike
and many factors need to be considered when creating a plan.
Additionally, depending on which product you are using, you need to build around
that specific product. For example, Sage ERP MAS 200 SQL has a System database,
Company databases, and static files (flat files) on the Application Server. A disaster
recovery plan should define which databases and files would have to be backed up on
a regular basis. The process also needs to determine where and how these files should
be protected. The restore process would then determine the steps to restore the
required files in order to bring the application back on line in case of data loss.
Differences Between Disaster Recovery and High Availability
2
Disaster recovery entails restoring your system back to normal after a catastrophic
failure or extended outage. High availability typically involves local context, such as
keeping downtime to a minimum from day to day. Both involve people and processes
more than technology.
Creating a Plan
You should protect your system from user, database, and system errors, operating
system issues, hardware and application failures, security breaches, and external
issues, such as weather, power, etc.
Expect the Unexpected
You have to realize that outages will occur - the question is when; therefore, you must
be prepared to minimize or prevent common causes of downtime and outages. You
should also be proactive with people, processes, and technology.
Service Level Agreements
Service level agreements should be determined early in any project and should
include the following two objectives. The goal is to have no loss or downtime.
Recovery time objective (RTO)
Recovery point objective (RPO)
SQL Server Fundamentals Planning for Disaster Recovery
Page 230 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Planning for Disaster Recovery (continued)
2
What Defines Downtime?
First, you need to define what is considered downtime.
Planned vs unplanned
When systems are up but applications unusable
When systems are up but the network is down or too slow
Rebuilding After a Disaster
You should know ahead of time how to rebuild after a disaster. Considerations include
the following:
How to rebuild?
Where to rebuild?
Site access
Site restrictions
Security
Requirements
Requirements for a disaster recovery plan include the following:
Must meet Service Level agreements.
Must take into account the capabilities including technical and non-technical.
Must work within the budget.
Must be tested periodically.
Actions
Some things to consider when developing actions for the disaster recovery plan
includes:
Need clear steps, escalation points, and timelines.
The plan must be accessible.
Everything should be documented, including while being performed.
The call list should be up-to-date.
You should periodically revisit and revise the plan.
Certified Student Course Curriculum - Version 2.0 Page 231
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Planning for Disaster Recovery
Planning for Disaster Recovery (continued)
2
The Plan
The disaster recovery plan should include the following:
Must have a chain of command and someone must be in charge.
The correct people need to be in the correct role with no single points of failure.
People need to have the correct training and available, workable schedules
Support Contracts
Some things to think about regarding support contracts include:
Support contracts are often the deciding factor.
Must know who to contact, regarding hardware and software components.
Must understand and agree to the Service Level agreement.
Must know how to contact.
- Up-to-date call list
- Contract numbers and relevant information
Applications
Some things to think about regarding applications include:
Will the applications support a move to another server easily?
High availability and disaster recovery must be part of the initial plan.
SQL Server
Some things to think about regarding SQL Server include:
Backing up and restoring
Log shipping
Attaching/detaching databases
Database snapshots
Database mirroring
bcp utility (for bulk copy data between and instance of SQL Server and a data file
SQL Server Integration Services (SSIS)
Replication (more for data distribution than high availability or disaster recovery)
SQL Server Fundamentals High Availability Options
Page 232 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
High Availability Options
2
This section outlines some options you can use for high availability and also outlines
some barriers to availability.
Database Snapshots
Information about database snapshots includes the following:
Database snapshots are read only
Provides a static view of the database
Transaction consistent at point of time
Does not store all data pages
Reads only the original data pages
- Reads data from the snapshot if data has changed
- Reads data from the database if data has not changed
Increases I/0 of source database
The following illustration shows how database snapshots work:
Some database snapshot scenarios include:
Enabling mirroring database for reporting
Historical point-in-time reporting
Recovering from administrative error
Protecting against application or user error
Certified Student Course Curriculum - Version 2.0 Page 233
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals High Availability Options
High Availability Options (continued)
2
Barriers to Availability
Some barriers to availability include:
Business requirements, such as time and location, processes, and expectations.
Technology, such as hardware, DBMS software, and application software.
Primary server or DBMS barriers include:
- User or application error, such as accidental or malicious data modifications.
- Data access concurrency limitations, such as multiple transactions accessing
the same data and persistent data structure changes.
Failover Clustering
Some things to note about failover clustering include:
Failover clustering is aimed at server failure.
It is built on Microsoft Cluster Services (MSCS).
- Multiple nodes
- Automatic failover of instance
- Pass Cluster Validation for SQL Server 2008
There is zero-committed work loss.
Single copy of instance databases.
Supports a variety of SQL Server components.
SQL Server Fundamentals High Availability Options
Page 234 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
High Availability Options (continued)
2
The following illustration shows how failover clustering works.
Database Mirroring
Some things to note about database mirroring include:
Provides a hot standby (near instant)
Database failover
- Very fast automatic failover
- Can provide transparent client redirect
Zero committed work loss
There is some performance impact
Can have a maximum of one mirror for each database
Certified Student Course Curriculum - Version 2.0 Page 235
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals High Availability Options
High Availability Options (continued)
2
The following illustration shows how database mirroring with automatic failover
works.
SQL Server Fundamentals High Availability Options
Page 236 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
High Availability Options (continued)
2
Log Shipping
Some things to note about log shipping include:
It is a mature and reliable technology
There is no automated failover
It is essentially a process of:
- Back up transaction logs
- Copy logs to another server
- Restore the logs
Replication
Some things to note about replication include:
Mostly should be considered as a data distribution technology
Has many forms:
- Transactional
- Merge
- Snapshot
Not commonly used for High Availability
- Peer to peer transactional replication has a potential role
Certified Student Course Curriculum - Version 2.0 Page 237
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals High Availability Options
High Availability Options (continued)
2
Comparison of High Availability Options
The following charts compare the high availability features:
SQL Server Fundamentals Challenge Questions - Part X
Page 238 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Challenge Questions - Part X
2
1. Explain the difference between disaster recover and high availability.
_____________________________________________________
_____________________________________________________
_____________________________________________________
_____________________________________________________
_____________________________________________________
2. List at least three things a disaster recovery plan should include.
_____________________________________________________
_____________________________________________________
_____________________________________________________
SQL Server Fundamentals
Certified Student Course Curriculum - Version 2.0 Page 239
Copyright 2010 Sage Software, Inc. All rights reserved.
Appendix
3
The following topics are included in this Appendix:
Appendix A - Challenge Answers
Appendix B - Troubleshooting
Appendix C - Resources and References
SQL Server Fundamentals Challenge Answers
Page 240 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Appendix A Challenge Answers
4
page 29
1. List at least three things you should do before upgrading from SQL Server
2000/2005.
Document all existing systems.
Develop validation tests.
Develop performance benchmarks.
Capture baseline data for these.
Formulate and test a rollback plan.
Identify the upgrade stakeholders: application, database, hardware, infrastructure,
users, business sponsor.
page 65
1. Which utility should you run before installing SQL SErver 2008 if you are
upgrading from SQL Server 2000/2005?
Answer: The Install Upgrade Advisor available. which is available on the SQL
Server Installation Center window.
2. Explain briefly how to add a new server group in SQL Server Management
Studio.
Answer: In SQL Server Management Studio, select the View menu > Registered
Servers. Expand the Database Engine node and right-click a server or server
group. Select New Server Group. In the New Server Group Properties window,
enter a name and description for your new server group. You can then move
servers into your new server group folder.
Certified Student Course Curriculum - Version 2.0 Page 241
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Challenge Answers
Challenge Answers (continued)
5
page 79
1. Which tool in SQL Server provides management and security over the surface
area of local and remote instances on the SQL Server?
Answer: SQL Server Surface Area Configuration tool.
2. List at least three properties you can view and/or configure using the Server
Properties window.
Answer:
Determine where SQL Server is running.
Determine how much memory is being used by the server?
Determine how much memory is used for index and queries.
Determine how many processors are being used.
Determine the default fill factor.
Determine where the system default for new databases are to be stored.
View or set the network packet size.
View or set the authentication mode.
View or set permissions.
page 109
1. What is the quickest way to view the properties of a database in SQL Server?
Answer: Right-click the server name in SQL Server Management Studio.
2. Which page in the Database Properties window is used to set the options of the
database?
Answer: Options
3. What are the three recovery models?
Answer: FULL, BULK_LOGGED, SIMPLE
4. Explain how to quickly create a table in SQL Server?
Answer: In SQL Server Management Studio, expand the database you are adding
the table to. Next, right-click and select New Table. Create the columns fo the
table and define the data types. Make sure to create a primary key for one of the
columns. Save the table (File menu > Save Table_1).
SQL Server Fundamentals Challenge Answers
Page 242 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Challenge Answers (continued)
6
page 123
1. Which option under the Management node allows you to enforce policies for
configuring and managing SQL Server across an enterprise?
Answer: Policy Management
2. Which option under the Management node allows you to manage SQL Server
workload and system resource consumption?
Answer: Resource Governor
3. What does the SQL Server Logs option under the Management node allow you to
do?
Answer:
Record processes that have been completed successfully, such as backup and
restore operation, batch commands, and scripts.
Detect any problems with SQL Server, such as automatic recovery messages.
page 147
1. Which node in SQL Server Management Studio contains tools that allow you to
create alerts, jobs, and operators?
Answer: SQL Server Agent
2. Explain briefly how to create a job and a step within a job.
Answer: In SQL Server Management Studio, expand the SQL Server Agent node
and then right-click the Jobs node. After defining the job information on the
General page, select Steps and then click New. You can the enter the information
and parameters to use for the step in the New Job Step window. Click OK.
page 172
1. Name a feature in SQL Server that can be used to determine resource bottlenecks
regarding CPU, memory, and disk input/ouput.
Answer:
2. List at least three standard reports that come with SQL Server that show
information for troubleshooting problems.
Disk Usage
Disk Usage by Top Tables
Disk Usage by Partition
Certified Student Course Curriculum - Version 2.0 Page 243
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Challenge Answers
Challenge Answers (continued)
7
page 192
1. What are the three types of backups you can perform in SQL Server?
Answer:
Full
Differential
Transaction log
2. What is an alternative to backing up and restoring a database?
Answer: Detaching the database from one server and then attaching the database
to another server.
page 204
1. List at least three tasks that you can include in a maintenance plan.
Answer:
Check for data consistency
Shrink a database
Update statistics
Clean up history
Execute SQL Server Agent jobs
Back up databases
Rebuild and reorganize indexes
2. After creating your maintenance plan, which two places can you view it from
within SQL Server Management Studio?
Answer:
Under the Management > Maintenance Plans node
Under the SQL Server Agent > Jobs node
SQL Server Fundamentals Challenge Answers
Page 244 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Challenge Answers (continued)
8
page 227
1. List at least one business case for using SQL Server Integration Services.
Answer:
Importing and exporting data from relational databases
Populating data warehouses (ETL)
Cleaning and standardizing data
Merging data from heterogeneous data stores
Automating administrative tasks
2. Which two deployment tools can be used with SSIS packages?
Answer:
Development Utility
Package Installation Wizard
page 238
1. Explain the difference between disaster recover and high availability.
Answer: Disaster recovery involves restoring your system back to normal after a
catastrophic failure or extended outage. High availability typically involves local
context, such as keeping downtime to a minimum from day to day. Both involve
people and processes more than technology
2. List at least three things a disaster recovery plan should include.
Answer:
Must have a chain of command and someone must be in charge.
The correct people need to be in the correct role with no single points of
failure.
People need to have the correct training and available, workable schedules
9
Certified Student Course Curriculum - Version 2.0 Page 245
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Troubleshooting
Appendix B Troubleshooting
10
Detecting an Indexing Issue
In the following case, it is suspected that a particular query is consuming significant
resources on the server. The query is not overly complex but is executed frequently.
You need to investigate the query.
Steps for Viewing a Query In Action
1. If you are not in SQL Server Management Studio, access it now from the Start
menu > All Programs > Microsoft SQL Server 2008.
2. Make sure you have the Object Explorer pane open (View menu > Object
Explorer).
3. Expand the Database node.
4. Right-click the mas500_app database and select New Query.
Click this button to
access the Query
Options window.
SQL Server Fundamentals Troubleshooting
Page 246 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Troubleshooting (continued)
11
5. On the Query toolbar, click the Query Options button.
6. Under the Execution node, select Advanced.
7. Select the SET STATISTICS IO check box.
Note: For this example, we set this option so that each time we execute a query,
we will see statistics of I/O returned on the Messages tab. This will help when
tuning the queries.
8. Click OK to save the query.
Certified Student Course Curriculum - Version 2.0 Page 247
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Troubleshooting
Troubleshooting (continued)
12
9. Click the Query menu in the SQL Server Management Studio window.
10. Make sure Include Actual Execution Plan is selected. (An icon will display beside
it, indicating whether it is selected.)
Note: We are setting this option so that each time a query is executed, we can see
the execution plan that was used to execute the query. This is a plan generated as a
query is executed rather than an Estimated Execution Plan that can be produced
for some queries without the need to execute them. The option for an Estimated
Execution Plan is also on the Query menu.
11. In the main query window, type the following query




12. Execute the query by clicking the Execute button. Note the results returned in the
Results tab.
13. Click the Messages tab and review the output.

SQL Server Fundamentals Troubleshooting
Page 248 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Troubleshooting (continued)
13
14. In the example above, the output indicates that 300 logical page reads were
required to execute the query. Scan count can now be misleading and should be
ignored.
15. Click the Execution Plan tab and note the output.
In this example, the query is being executed by scanning the clustered index on
the table. That is estimated at 84% of the cost of the query and is a key aspect we
wish to avoid the need for. After the data has been obtained, an additional 16% of
the cost is consumed in sorting the output.
16. Switch to SQL Server Management Studio, expand the Databases node > expand
the mas500_app node > expand the Tables node > expand the dbo.tsmPostalCode
> then expand the Indexes node.
At this point notice that two indexes exist. The table is clustered on the CountryID
and PostalCode columns and there is a non-clustered index on the PostalCode and
CountryID columns. Neither of these indexes is a great solution for a query that
needs to locate rows for a particular StateID.
17. Hover over each of the operators in the execution plan and note the values in the
pop-up for each.
18. Note the warning about a Missing Index in the execution plan. Right-click in a
whitespace area of the plan and select Missing Index Details
Certified Student Course Curriculum - Version 2.0 Page 249
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Troubleshooting
Troubleshooting (continued)
14
19. Edit the new query window to resemble the following:
20. Execute the query by clicking the Execute button to create the new index.
21. Click back on the previous query window.
22. Execute the original query again by clicking the Execute button.
Note that the query returns the same data but quicker.
23. Click the Messages tab and note the reduction in logical page reads required to
execute the query.
24. Click the Execution Plan tab and note that the missing index hint has disappeared.
Note also that our newly created index is being chosen by the system. This is a
good indication that we've helped. If SQL Server ignores your new index, it's
probably the wrong index.
Note that the sort operation is still required.
While the Missing Index Dynamic Management View can provide good hints
about indexing structure, a trained DBA can often provide an index that will
outperform the hints.
25. Click back to the query window we used to create the index and modify its
contents to create another index.
26. Execute the query by clicking the Execute button to create the new index.
SQL Server Fundamentals Troubleshooting
Page 250 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Troubleshooting (continued)
15
27. Click back on the query window with the original query and re-execute it by
clicking the Execute button. Note the results on the Results tab:
We have not reduced the number of logical page reads. Small page read values
such as this are very hard to reduce and lower values would possibly be
misleading anyway. It would also be a waste of effort to try to go much further.
There will no doubt be bigger issues on the system to investigate.
28. Click the Execution Plan tab and review the output.
The sort operation is now unnecessary. Note that it's hard to read the name of the
index that has been used while in this view. Hover over the Index Seek operator
and note from the Object section that it is indeed our newly created index that has
been chosen.
29. Navigate to the list of indexes for this table in Object Explorer again, refresh the
list (right-click then Refresh) and note the new indexes. Delete the first version of
the index we created.
Note: A very common error is to create indexes that aren't going to be used and to
forget to delete them later. Unnecessary indexes can cause significant overhead to
transactional systems
Certified Student Course Curriculum - Version 2.0 Page 251
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Resources and References
Appendix C Resources and References
15
There are several SQL Server resources that are available to help you understand the
features and functionality, and expand your knowledge of SQL Server.
SQL Server Books Online
SQL Server Books Online is the comprehensive resource for anything relating to SQL
Server. These files are originally shipped with your SQL media, and installed when
you perform a typical installation type.
This online resource provides detailed documentation of all the SQL Server
functionality available. You can access the SQL Server Books Online at the following
location if you did not install it with SQL Server:
http://msdn.microsoft.com/en-us/library/ms130214.aspx
Some of the topics that are covered include:
How to Install SQL Server
SQL Server / Architecture
Administering SQL Server
Creating and Maintaining a Database
Optimizing the Database
XML and Internet Support
Transact-SQL reference
Building SQL Applications
Understanding Surface Area Configuration
Database Engine
Analysis Services
Integration Services
Reporting Services
Data Mining
SQL Server Fundamentals Resources and References
Page 252 Certified Student Course Curriculum - Version 2.0
Copyright 2010 Sage Software, Inc. All rights reserved.
Resources and References (continued)
16
If you installed SQL Server Books Online during your SQL Server installation,
Microsoft has updates you can download. It is recommended you install the updated
version to access the most recent information.
You can obtain the updates from www.microsoft.com/downloads and search for SQL
Server Books Online.
The Update version contains the following information:
Suggestions sent to Microsoft by customers using the feedback button available in
every topic of SQL Server Books Online.
Corrections of documentation errors reported after the release of the last update to
SQL Server Books Online.
New and updated error messages.
Additional SQL Resources on the Web
Microsoft SQL Server 2008- http://www.microsoft.com/sqlserver/2008/en/us/
Microsoft msdn library - http://msdn.microsoft.com/en-us/library/default.aspx
Microsoft Support - http://www.microsoft.com/sql/support/default.asp
For information about how to use Microsoft Update to identify updates for SQL
Server 2008, see the Microsoft Update website at
http://go.microsoft.com/fwlink/?LinkId=108409
Certified Student Course Curriculum - Version 2.0 Page 253
Copyright 2010 Sage Software, Inc. All rights reserved.
SQL Server Fundamentals Resources and References
Resources and References (continued)
17
References
msdn website articles at www.msdn.microsoft.com
- SQL Server Overview
- SQL Server Administration Tools
- Hardware and Software Requirements for Installing SQL Server 2008
- Introducing SQL Server Management Studio
- SQL Server Agent
- Activity Monitor
- How to: Create a Database (SQL Server Management Studio)
- Installing SQL Server 2008
- Maximum Capacity Specifications for SQL Server
Microsoft website articles at www.microsoft.com
- SQL Server 2008 Features Comparison
Sage/Microsoft Joint SQL Server Training - February 2010
By default, sample databases and sample code are not installed as part of SQL
Server Setup.
- To install sample databases and sample code for non-Express editions of SQL
Server 2008, see the CodePlex website at http://go.microsoft.com/fwlink/
?LinkId=87843
- To read about support for SQL Server sample databases and sample code for
SQL Server Express, see Databases and Samples Overview on the CodePlex
website at http://go.microsoft.com/fwlink/?LinkId=110391
For more information about late-breaking changes in this release of SQL Server,
see the latest readme file at http://go.microsoft.com/fwlink/?LinkId=100093

You might also like