1. Trang chủ
  2. » Công Nghệ Thông Tin

Hướng dẫn học Microsoft SQL Server 2008 part 14 pdf

10 359 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 10
Dung lượng 1,55 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Client ConnectivityIN THIS CHAPTER Enabling server connectivity SQL Native Client development features Client software connectivity SQL Server 2008 follows Microsoft’s philosophy of ‘‘se

Trang 1

Nielsen c04.tex V4 - 07/23/2009 1:58pm Page 92

Trang 2

Client Connectivity

IN THIS CHAPTER

Enabling server connectivity SQL Native Client development features

Client software connectivity

SQL Server 2008 follows Microsoft’s philosophy of ‘‘secure by default’’ and

reduces the surface area of the application The initial installation allows

local access only — no network connections for the Express and Developer

editions (i.e., remote client applications will not be able to connect)

Chapter 4, ‘‘Installing SQL Server 2008’’ discusses SQL Server surface area configuration as part of the installation process.

The Server Configuration Manager tool installed with SQL Server can nearly

always communicate with SQL Server so you can configure the server connectivity

options and open the server up for network access The connectivity relies on

open paths between the client and server machines At times, there will be

firewall issues to deal with

With network access allowed on the SQL Server, SQL Server provides clients with

a new means of accessing functionality and features through the new SQL Server

Native Client (SNAC) Before getting into the SNAC, network access for the new

server must be enabled

Enabling Server Connectivity

When initially installed, SQL Server enables the Shared Memory protocol and

dis-ables the remaining protocols This provides the greatest default security because

only applications running locally to the SQL Server can connect

To broaden SQL Server availability, additional network protocols must be enabled

on the server

Trang 3

Nielsen c05.tex V4 - 07/21/2009 12:19pm Page 94

Part I Laying the Foundation

What’s New in 2008 Connectivity

SNAC supports table value parameters Table-valued parameters are a new parameter type in SQL Server

2008

There is a new SNAC OLE DB provider You’ll need to get version 10 of SNAC

Also of note for developers, Microsoft Data Access Components (MDAC) is compatible with SQL 2008 but

will not be enhanced to support the new 2008 SQL Server features

Chapter 39, ‘‘Configuring SQL Server,’’ discusses SQL Server configuration in detail.

Server Configuration Manager

When managing SQL Server services, configuring network protocols used by SQL server, or managing

the network connectivity configuration from client computers, SQL Server Configuration Manager is the

tool you need

Network protocols define the common set of rules and formats that computers and

applica-tions use when communicating with one another Table 5-1 lists the protocols available in SQL

Server

TABLE 5-1

SQL Server Protocols

Protocol Description

Shared Memory This is an in-memory protocol and thus is only suitable for applications that are

running on the same machine as the SQL Server

Named Pipes This is an interprocess communications protocol (IPC) that enables a process to

communicate with another process, possibly running on a different computer, through the use of shared memory This protocol typically works well in small and fast local area networks, as it generates additional network traffic during use In larger and slower networks, TCP/IP works better

TCP/IP TCP/IP, or Transmission Control Protocol/Internet Protocol, is widely used

today TCP guarantees the delivery and order of the information sent between computers, while IP defines the format or structure of the data sent TCP/IP also contains advanced security features that make it attractive to security-sensitive organizations and users This protocol works well in larger networks and slower networks

Trang 4

With the Configuration Manager, you can enable, disable, and configure these various protocols as

appropriate for the operational environment The utility may be launched from the Start menu by

selecting Start➪ All Programs ➪ Microsoft SQL Server 2008 ➪ Configuration Tools ➪ SQL Server

Configuration Manager The Server Configuration Manager presents a list of all the available protocols

and communication options, as shown in Figure 5-1

FIGURE 5-1

The SQL Server Configuration Manager establishes the connectivity protocols used by SQL Server to

communicate with clients

All TCP/IP communications is done over a specified port Well-known ports include HTTP (port 80),

FTP (port 21), and SSL (port 443) In most cases, SQL Server communicates over port 1433 when using

TCP/IP If communications are sent through a firewall, this can cause the communication to block Port

1433 must be opened in a firewall in order for communications to be possible

You can change the port number for instances of SQL Server In this way, you can map instances to

specific TCP/IP ports When you do this, make sure that there is an opening in the firewall for any ports

that you need

Having trouble connecting with your SQL Server? Check these items:

■ Does the server allow remote connections?

■ Do both the server and the client speak the same protocol?

■ Can the client ping the server?

■ Is port 1433 (the SQL Server default port) open on the server’s firewall?

■ Is SQL Browser service running?

SQL Native Client Connectivity (SNAC)

The SQL Native Client connectivity is managed through the same Server Configuration Manager SNAC

installations will initially default the network protocols to enabling Shared Memory, TCP/IP, and Named

Pipes, as shown in Figure 5-2

Trang 5

Nielsen c05.tex V4 - 07/21/2009 12:19pm Page 96

Part I Laying the Foundation

FIGURE 5-2

The SQL Server Configuration Manager view for SQL Native Client Configuration Client Protocols

SNAC also adds support for large User Defined Types (UDT) This enables developers to create custom

types of any arbitrary size In addition, SNAC supports table value parameters New to 2008 are

table-valued parameters, which are used to send multiple rows of data to a T-SQL statement or routine

with-out creating multiple other parameters or a temporary table You declare a table-valued parameter with

user-defined table types

There is also a new SNAC OLE DB provider, which offers much better performance It also makes

parameterized queries much more efficient

If SNAC access is not needed or supported by your organization, disabling the appropriate network

pro-tocols will reduce your security risks (surface area)

SQL Server Native Client Features

The development community gains access to the new features of SQL Server 2008 through the SQL

Server Native Client (SNAC) If the new features are not needed and managed code is a requirement

for data access, then ADO.NET will suffice While a detailed examination of the features is beyond the

scope of this chapter, a summary of each is provided

ADO.NET is an umbrella label applied to the NET functionality that supports connections

to a variety of data sources Classes within this library supply the programmatic capability

to create, maintain, dispose of, and execute actions against a database.

For developers, Microsoft Data Access Components (MDAC) is compatible with SQL 2008 but will not

be enhanced to support the new 2008 Server features

Because SQL Server Native Client is a component of SQL Server 2008, it must be installed separately on the development machine and must be included with the application setup.

Microsoft has included the sqlncli msi file on the SQL Server installation DVD This file installs SQL

Server Native Client without requiring the full SQL Server installation DVDs.

Trang 6

The software requirements for installing and running SQL Server Native Client are listed in Table 5-2

The operating system dictates the hardware requirements, including memory, hard disk capacities, CPU,

and so on

Chapter 4, ‘‘Installing SQL Server 2008,’’ provides details about SQL Server installation

requirements.

TABLE 5-2

SNAC Installation Requirements

Installer Operating Systems Compatible SQL Server

Windows Installer 3.0 Windows XP SP1 or later

Windows 2000 Professional Windows 2000 Server Windows 2000 Advanced Server Windows 2000 Datacenter Windows 2003 Server Windows 2003 Enterprise Server Windows 2003 Datacenter Server Windows Vista

Windows 2008 Server Windows 2008 Enterprise Server

SQL Server 7.0 or later supports connectivity

Asynchronous operations

There are times when not waiting on a return from the database call is desirable It is now possible to

open and close a database connection without waiting by setting the appropriate property

Additionally, asynchronous calls returning result sets can be made In these cases, a valid result set will

exist but may still be populating Therefore, it is necessary to test the asynchronous status of the result

set and process it when it is complete

There are some caveats to performing asynchronous operations such as connection pooled

objects and use of the cursor’s engine The asynchronous status is not exposed.

Multiple Active Result Sets (MARS)

SQL Server 2008 provides support for multiple active SQL statements on the same connection This

capability includes being able to interleave reading from multiple results sets and being able to execute

additional commands while a result set is open

Microsoft guidelines for applications using MARS include the following:

■ Result sets should be short-lived per SQL statement

Trang 7

Nielsen c05.tex V4 - 07/21/2009 12:19pm Page 98

Part I Laying the Foundation

■ If a result set is long-lived or large, then server cursors should be used

■ Always read to the end of the results and use API/property calls to change connection

properties

By default, MARS functionality is not enabled Turn it on by using a connection string value — MarsConn for the OLE DB provider and Mars _ Connection for the ODBC provider.

XML data types

Much like the currentVarChardata type that persists variable character values, a new XML data type

persists XML documents and fragments This type is available for variable declarations within stored

pro-cedures, parameter declarations, and return types and conversions

User-defined types

These types are defined using NET common language runtime (CLR) code This would include the

pop-ular C# and VB.NET languages The data itself is exposed as fields and properties, with the behavior

exposed through the class methods

Large value types

Three new data types have been introduced to handle values up to 2 ˆ 31-1 bytes long This

includes variables, thus allowing for text values in excess of the old 8K limit The new types and their

corresponding old types are listed in Table 5-3

TABLE 5-3

New SQL Server 2008 Large Values Types

New Large Data Types Prior Data Types

Handling expired passwords

This new feature of SQL Server 2008 enables users to change their expired password at the client

with-out the intervention of an administrator

A user’s password may be changed in any of the following ways:

■ Programmatically changing the password such that both the old and new passwords are

provided in the connection string

■ A prompt via the user interface to change the password prior to expiration

■ A prompt via the user interface to change the password after expiration

Trang 8

Best Practice

If the old and new passwords are supplied on the connection string, then ensure that this information has

not been persisted in some external file Instead, build it dynamically to mitigate any security concerns

Snapshot isolation

The new snapshot isolation feature enhances concurrency and improves performance by avoiding

reader-writer blocking

Snapshot isolation relies on the row versioning feature A transaction begins when the

BeginTransactioncall is made but is not assigned a sequence transaction number until the

first T-SQL statement is executed The temporary logical copies used to support row versioning are

stored intempdb

If tempdb does not have enough space for the version store, then various features and operations such as triggers, MARS, indexing, client executed T-SQL, and row versioning will fail, so ensure that tempdb has more than enough space for anticipated uses.

Summary

SQL Server Configuration Manager now provides the server and SQL Native Client protocol

manage-ment SQL Server 2008 supports new features that enrich the client and programmatic data experience

By accessing these new features through the SQL Server Native Client (SNAC), developers are now able

to enhance the user experience by providing integrated password changes, improved blocking, and

better user interface response with asynchronous calls In addition, stability increases significantly with

the use of mirrored servers and other useful features

Trang 9

Nielsen c05.tex V4 - 07/21/2009 12:19pm Page 100

Trang 10

Using Management

Studio

IN THIS CHAPTER

A UI worthy of SQL Server 2008

Navigating SQL Server’s objects

Organizing projects Maximizing productivity with Query Editor

SQL Server’s primary user interface is SQL Server Management Studio

(SSMS), a powerful set of tools within a Visual Studio shell that enables

the developer or DBA to create database projects and manage SQL

Server with either a GUI interface or T-SQL code For business intelligence

(BI) work with Integration Services, Reporting Services, and Analysis Services,

there’s a companion tool called SQL Server Business Intelligence Development

Studio (BIDS)

Like many things in life, Management Studio’s greatest strength is also its

great-est weakness Its numerous tasks, tree nodes, and tools can overwhelm the new

user The windows can dock, float, or become tabbed, so the interface can appear

cluttered, without any sense of order

However, once the individual pages are understood, and the interface options

mastered, the studios are very flexible, and interfaces can be configured to

meet the specific needs of any database task Personally, I love Management

Studio — it’s one of my favorite features of SQL Server 2008

Much of using Management Studio is obvious to experienced IT professionals,

and subsequent chapters in this book explain how to accomplish tasks using

Management Studio, so I’m not going to explain every feature or menu item

in this chapter Instead, this chapter is a navigational guide to the landscape,

pointing out the more interesting features along the way

Management Studio is backwardly compatible, so you can use it to manage SQL Server 2008 and SQL Server 2005 servers It’s SMO-based, so some features may work with SQL Server 2000, but

it’s not guaranteed to be compatible.

A common misconception among new SQL Server DBAs is that Management

Stu-dio is SQL Server It’s not Management StuStu-dio is a front-end client tool used to

manage SQL Server and develop databases Typically, Management Studio is run

Ngày đăng: 04/07/2014, 09:20

TỪ KHÓA LIÊN QUAN