In this lesson, you will learn about:• Configuring and Using SQLMail • Configuring and Using SQLAgentMail • Configuring and Managing Linked Servers • Introducing IIS virtual directories
Trang 1In this lesson, you will learn about:
• Configuring and Using SQLMail
• Configuring and Using SQLAgentMail
• Configuring and Managing Linked Servers
• Introducing IIS virtual directories to support Extensible Markup Language
(XML)
In this lesson, you will learn about:
Configuring and Using SQL Mail
Configuring and Using SQLAgentMail
Configuring and Managing Linked Servers
Trang 2Additional Features of SQL Server Lesson 3A / Slide 2 of 26
©NIIT
Additional Features of SQL Server
2000
Pre-Assessment Questions
1 Which of the following SQL Server 2000 job step helps SQL Server
Agent to find the application source?
a) Operating system commands b) Transact-SQL statements c) Microsoft ActiveX scripts d) Replication tasks
2 Which of the following attributes of SQL Server alerts and their
messages contains the name of the stored procedure, if the error has
occurred in a stored procedure?
a) State code b) Procedure name c) Line number d) Message string
Trang 3Additional Features of SQL Server Lesson 3A / Slide 3 of 26
b) It is used to find the source code location of the error and is used by Microsoft support engineers
c) It indicates the line number of the Transact-SQL statement in the stored procedure, which has caused the error
d) It contains the name of the stored procedure if the error has occurred in a stored procedure
Trang 4Additional Features of SQL Server Lesson 3A / Slide 4 of 26
©NIIT
Additional Features of SQL Server 2000
Pre-Assessment Questions
4 From the following options, which attribute of the SQL Server alert
contains the name of the stored procedure that has generated the
error?
a) Severity b) Message string c) Procedure name d) State code
5 From the following options which job step of SQL Server 2000 contains the full path to all the executable files and command?
a) CMDExec commands b) Transact-SQL statements c) Microsoft ActiveX scripts d) Replication tasks
Trang 5Additional Features of SQL Server Lesson 3A / Slide 5 of 26
©NIIT
Additional Features of SQL Server 2000
Solutions to Pre-assessment Questions:
Ans 1 a Operating system commands Ans 2 b Procedure name
Ans 3 b It is used to find the source code location of the error and is used by Microsoft support engineers.
Ans 4 c Procedure name Ans 5 a CMDExec commands
SQL Mail
SQLAgentMail
Linked Server
SQL Server XML support in IIS
Discuss the functions of SQL Mail and tell the students about the xp_sendmail system
Trang 6SQLAgentMail Also tell the students about the various system-stored procedures used
by SQLAgentMail during its execution Now tell the students that before using SQL Mail and SQL AgentMail you need to configure MAPI clients on SQL Server 2000 Then discuss linked server and SQL Server XML support in IIS in brief
Ensure that the following datafiles are installed on the student nodes:
Employee.mdb
Customers.mdb
Trang 8Additional Features of SQL Server Lesson 3A / Slide 7 of 26
• SQL Server 2000 sends and receives messages by establishing a connection
with mail servers.
• SQL Mail is the mail service of SQL Server 2000 that sends messages to
mailboxes and e-mail pagers using the Transact-SQL commands and
xp_sendmail extended stored procedure.
• You can also create a scheduled job for automatic process of e-mail.
Trang 9Additional Features of SQL Server Lesson 3A / Slide 8 of 26
• The following table lists the SQL Mail stored procedures and their description:
Finds the next message in the SQL Server inbox for processing xp_findnextmsg
Deletes specified messages xp_deletemail
Processes queries as an incoming messages and sends the result set to the designated recipients as an outgoing message
Trang 10Additional Features of SQL Server Lesson 3A / Slide 9 of 26
• SQLAgentMail is the mail service of SQL Server 2000 that is used for SQL
Server Agent services.
• Before configuring SQL Mail and SQLAgentMail, you need to install MAPI clients
on the SQL Server 2000 computer.
• Linked server is a component of SQL Server 2000 that links multiple database servers to facilitate exchange of information.
Trang 11Additional Features of SQL Server Lesson 3A / Slide 10 of 26
Text Files
Oracle DB Server
SQL Server
Trang 12Additional Features of SQL Server Lesson 3A / Slide 11 of 26
2000 supports XML for exchange of information across platforms SQL Server 2000 also provides features for accessing databases through Internet servers, such as IIS
To take advantage of all these features, you need to configure the following
components:
SQL Mail
SQLAgentMail
Linked Server
SQL Server XML support in IIS
SQL Server 2000 sends and receives messages by establishing a connection with mail servers SQL Server 2000 supports mail servers such as, Microsoft Exchange Server, Microsoft Windows Mail, or Post Office Protocol 3 (POP3) The mails are sent and received using two separate services, SQL Mail and SQLAgentMail Both these services require Messaging Application Programming Interface (MAPI) client applications, such
as Microsoft Outlook and MAPI messaging profile on SQL Server 2000 computer
Trang 13MAPI is an interface of Microsoft Windows program that enables you to send and receive e-mail within Windows application The services also require Windows NT 4.0
or Windows 2000 domain user account to logon to an instance of SQL Server 2000
SQL Mail
SQL Mail is the mail service of SQL Server 2000 that sends messages to mailboxes
and e-mail pagers using the Transact-SQL commands and xp_sendmail extended
stored procedure It receives and processes mails from a mail system and sends the query response to the designated mail account by creating a reply mail You can use a result set from a query, a message string, a Transact-SQL statement, or a page for an electronic pager as the content of an e-mail message For example, consider the following statements:
EXEC xp_sendmail ‘Scott@Macaluminium.USA’,
@subject = ’Database Login Information’,
@query = ‘Select * from master.dbo.master’
The Transact-SQL statement in the preceding example is a part of the content of the e-mail message You can also create a scheduled job for automatic process of e-mail The following table lists the SQL Mail stored procedures and their description:
xp_sendmail Sends e-mail messages from Transact-SQL batches,
scripts, triggers, and procedures to the designated user
xp_readmail Reads the message
xp_startmail Starts the session of SQL Mail
xp_stopmail Stops the session of SQL Mail
xp_deletemail Deletes specified messages
xp_findnextmsg Finds the next message in the SQL Server inbox for
processing
Trang 14SQLAgentMail
SQLAgentMail is the mail service of SQL Server 2000 that is used for SQL Server
Agent services SQL Server Agent services are server components that run scheduled
SQL Server 2000 administrative tasks SQLAgentMail is used to send e-mail
notifications to the designated users when any scheduled task, such as database backup or recovery, succeeds or fails You can configure SQLAgentMail to send SQL Server alerts when specific event occurs For example, you can use SQLAgentMail to send an alert to the operators when a particular database event needs immediate action SQLAgentMail uses its own mail profile and domain account These mail profiles and domain accounts are different from that of SQL Mail
Prerequisite for Configuring SQL Mail and
Apart from stored procedures, triggers and alerts can also be coded to send messages using the SQL Mail system
Trang 15Linked Server
Linked server is a component of SQL Server 2000 that links multiple database servers
to facilitate exchange of information Using this component you can connect or link multiple database servers, such as Oracle, and Microsoft Access using OLEDB data source and OLEDB data providers While you configure the linked server, you need to register the connection and data source information of the OLEDB data source with SQL Server 2000 After successful registration, you can always refer the data source with a single logical name Besides database servers, you can also link SQL Server
2000 database to a text file or a spreadsheet, as shown in the following figure:
You can create and configure the linked server, using SQL Server 2000 Enterprise Manager You can also create and configure a linked server using the
sp_addlinkedserver system stored procedure
SQL Server XML Support in IIS
SQL Server 2000 supports XML to convert an SQL Server 2000 instance into an XML enabled database server With the help of XML enabled database server, you can present the data on the web as XML pages in response to HTTP queries The
generated XML page can be used for exchanging information across different
platforms and organizations To do this, you need to configure IIS virtual directory The configured IIS virtual directory creates an association with the instance of SQL Server 2000 server that enables access to SQL Server 2000 database objects, such as tables through (Hypertext Transfer Protocol) HTTP In addition, you can also access the XML document consisting of one or more SQL statements
SQL Server
Trang 16I NSTRUCTOR N OTES
Additional Inputs
Using URL to Access SQL Server 2000
You can access SQL Server 2000 using the Uniform Resource Locator (URL) over the Hyper Text Transfer Protocol (HTTP) Using the URL you can:
1 Directly access the database objects, such as tables, view, or triggers of a SQL Server 2000 database However, this is not recommended due to security reasons
2 Execute the XML files containing Transact-SQL statements, known as
Trang 17C ONFIGURING SQL M AIL AND
Additional Features of SQL Server Lesson 3A / Slide 12 of 26
Trang 18Additional Features of SQL Server Lesson 3A / Slide 13 of 26
2 Expand the Microsoft SQL Server Group->Support Services option.
3 Right-click the SQL Mail option, and select the Properties option to
open the SQL Mail Configuration dialog box.
Trang 19Additional Features of SQL Server Lesson 3A / Slide 14 of 26
Trang 20Additional Features of SQL Server Lesson 3A / Slide 15 of 26
• To configure SQLAgentMail, perform the following steps:
1 Select Start->Programs->Microsoft SQL Server->Enterprise
Manager, to open the Enterprise Manager console.
2 In the Enterprise Manager console, expand the Microsoft SQL Server Group->Management container option.
Trang 21Additional Features of SQL Server Lesson 3A / Slide 16 of 26
Trang 22Additional Features of SQL Server Lesson 3A / Slide 17 of 26
4 In the Mail Session section, from the Mail profile drop-down list box
select the messaging profile as shown:
Trang 23Additional Features of SQL Server Lesson 3A / Slide 18 of 26
5 Click the Test button to verify the session of mail service.
Before configuring SQL Mail and SQLAgentMail, you need to install MAPI clients on the SQL Server 2000 computer In addition, you need to configure the mail or messaging profile of the domain user account SQL Mail and SQLAgentMail use these domain user accounts You can create the message profile using MAPI client interface or using Mail program in Control Panel
Configuring SQL Mail
To configure SQL Mail, perform the following steps:
1 Select StartÆAll ProgramsÆMicrosoft SQL ServerÆEnterprise Manager,
to open the Enterprise Manager console
2 Expand the Microsoft SQL ServersÆSQL Server Group Expand Support
Services under default instance of SQL Server, as shown
Trang 243 Right-click the SQL Mail option, and select the Properties option to open the SQL Mail Configuration dialog box
4 Select the profile name from Profile name list box
5 Click the Test button to verify the session of mail service
Trang 25Configuring SQLAgentMail
To configure SQLAgentMail, perform the following steps:
1 Select StartÆAll ProgramsÆMicrosoft SQL ServerÆEnterprise Manager,
to open the Enterprise Manager console
2 Expand the Microsoft SQL ServersÆSQL Server Group Expand
Management under default instance of SQL Server
3 Right-click the SQL Server Agent option, and then click the Properties option to open the SQL Server Agent Properties dialog box
4 In the Mail session section, from the Mail profile drop-down list box select
the messaging profile, as shown
5 Click the Test button to verify the session of mail service
Trang 26I NSTRUCTOR N OTES
Next, tell the students about configuring linked server in SQL Server 2000 To explain the configuration process of linked server, present the students with a business problem that requires configuring linked server Explain the solution of the problem in detail by breaking the solution in to several logically related tasks and then discussing these tasks in detail
Trang 27C ONFIGURING L INKED S ERVER
Additional Features of SQL Server Lesson 3A / Slide 19 of 26
©NIIT
Additional Features of SQL Server
2000
Configuring Linked Server
The Payroll department of Mac Aluminium, Inc., wants to prepare salary slips for the employees of Refractory department To do this, the Payroll department wants to collect the employee names and salaries of all the employees belonging to the Refractory department The Payroll department stores the data in SQL Server 2000 database, whereas the Refractory department uses MS Access database The system administrator of Payroll department wants to collect the required data from the Employee table stored in Employee.mdb database For easy identification, the system administrator wants to provide the name of the link as SQLMSACCESS As the system administrator is already authenticated by Windows operating system, the connection to SQL Server 2000 database will be a trusted connection.
Problem Statement
The Payroll department of Mac Aluminium, Inc., wants to prepare salary slips for the employees of Refractory department To do this, the Payroll department wants to collect the employee names and salaries of all the employees belonging to the Refractory department The Payroll department stores the data in SQL Server 2000 database, whereas the Refractory department uses MS Access database The system administrator of Payroll department wants to collect the required data from the Employee table stored in Employee.mdb database For easy identification, the system
administrator wants to provide the name of the link as SQLMSACCESS As the system
administrator is already authenticated by Windows operating system, the connection
to SQL Server 2000 database will be a trusted connection
Trang 28• Create a link between SQL Server 2000 and MS Access database server.
• Specify the connection information.
• Specify the connection mapping.
• Retrieve employee name and salary from Employee table.
To solve the preceding problem, perform the following tasks:
1 Create a link between SQL Server 2000 and MS Acesss database server
2 Specify the connection information
3 Specify the connection mapping
4 Retrieve employee name and salary from Employee table
1: Create a link between SQL Server 2000 and MS ACCESS database
Action:
1 Select StartÆAll ProgramsÆMicrosoft SQL ServerÆEnterprise Manager,
to open the SQL Server 2000 Enterprise Manager console