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

Microsoft SQL Server 2005 Express Edition for Dummies phần 9 pps

42 325 0

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

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Microsoft SQL Server 2005 Express Edition for Dummies phần 9 pps
Chuyên ngành Database and XML Applications
Thể loại sách hướng dẫn
Định dạng
Số trang 42
Dung lượng 1,03 MB

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

Nội dung

First, because XML is a built-in data type, you can use itanywhere within the database, Transact-SQL, or any of the supported 323 Chapter 21: Using XML with SQL Server 2005 Express... He

Trang 1

<reg:Duties>Not subject to duties</reg:Duties>

</reg:Instructions>

</Customer>

Continuing, you now see a nested element known as Customer, whose starttag is <Customer> and end tag is </Customer> This element itself containstwo nested elements, one known as Name, and the other known as

Identifier

It also contains a nested element known as Instructions This element andthose nested within it appear to be a little confusing, though What’s going on?Looking at the XML document listed earlier in the chapter, you may wonderhow your computer can keep things straight when handling XML receivedfrom different sources For example, what happens if you receive purchaseorders from two different organizations that use different element names andattributes that actually mean the same thing? Conversely, what happens ifthey use identical element names and attributes that mean different things?

This situation is where namespaces comes to the rescue Typically available

for consultation and review via the Internet, namespaces are assemblages of

element type and attribute names that help establish order and clear up fusion By providing a solid point of reference, they also assist when mergingsmaller subsets of XML documents

con-In this case, the document includes a link to a namespace server:

<reg:Instructions xmlns:reg=”http://www.samplenamespace.com/importexport”>

By specifying this namespace server, any applications that use this XML ument consult the namespace server for details about any elements or attrib-utes prefixed with reg A second namespace server comes up a little later inthe XML

doc-<Creator>Michael McManus</Creator>

Here’s an example of an element that tracks the purchase order’s creator Ithas no nested elements within; it is, however, nested within the purchaseorder element itself

<Product quantity=”1” price=”9.99”>GG2911</Product>

<Product quantity=”6” price=”54.94”>TK3020</Product>

Now you can see additional elements, both known as Product These ments have their own attributes, quantity and price in this case

ele-<ship:Shipment xmlns:ship=”http://www.samplenamespace.com/shipping”>

<ship:ShipDate>6/10/2007</ship:ShipDate>

<ship:Instructions>Contact Mr Hockney in receiving</ship:Instructions>

<ship:Instructions>Fax bill to Mr Kobayashi</ship:Instructions>

320 Part VI: Creating SQL Server 2005 Express Applications

Trang 2

Finally, the document contains an element known as Shipment, which itselfcontains nested elements called ShipDate and Instructions Notice that

to clear up confusion with the earlier reference to Instructions, a link isincluded to another namespace server:

One nice thing about using a specialized XML viewer is that you can expand

or collapse various elements Figure 21-2 shows how I collapsed some of theinner elements Imagine how useful this technique would be for an XML docu-ment containing thousands of lines of detail

Other important XML conceptsGetting up to speed on XML often involves digesting an intimidating alphabetsoup of acronyms and other jargon Earlier in the chapter, I show you some of

Figure 21-2:

A moreconciseview of anXMLdocument

Figure 21-1:

An XMLdocumentwithin theXML Editor

321

Chapter 21: Using XML with SQL Server 2005 Express

Trang 3

these concepts, but several remain However, you don’t need to worry: I’m asconcise as possible.

XML documents versus fragmentsThink of an XML document as a well-formed, fully complete set of XML-basedinformation that happens to have a root element On the other hand, an XMLfragment needs to be well formed, but by definition does not have a root ele-ment For example, look at the following fragment of XML, taken from thesample earlier in the chapter:

<Customer>

<Name>Soze Imports</Name>

<Identifier>21109332</Identifier>

<reg:Instructions xmlns:reg=”http://www.samplenamespace.com/importexport”>

<reg:Restrictions>Not subject to export control</reg:Restrictions>

<reg:Duties>Not subject to duties</reg:Duties>

</reg:Instructions>

</Customer>

This snippet is well-formed XML, and it even contains a reference to a server, but placing it into context is hard: There’s no indication of where itfits in the larger scheme of things

name-XML schema

An XML schema is a data structure that you define to help provide validation

constraints and other details about specific typed XML data (more about that

in the upcoming section) You can specify which attributes are mandatory,their formats, permissible quantities, and so on I show you an XML schema

in conjunction with database operations in the “Placing XML into Your SQLServer 2005 Express Database” section

Typed versus untyped XML

By referencing an existing XML schema collection, a column, parameter, or

variable is said to be typed Stand-alone XML that doesn’t reference a schema

is described as untyped The benefit of typed XML is that SQL Server 2005

Express performs all the data enforcement and validation rules specified inthe XML schema

When should you use XML?

This XML thing looks pretty good, don’t you think? You’re probably

wonder-ing, though, when you should put XML to work in your environment XML is

the right tool for the job for many good reasons:

322 Part VI: Creating SQL Server 2005 Express Applications

Trang 4

⻬ Standardized file format: More and more application developers are

using XML-based files to hold non database-hosted information Forexample, perhaps you’re building a software solution that will maintainits own configuration files In the past, you would have likely designed(and then had to maintain) your own customized text file With XML,you can leverage a predefined structure, along with all the software nec-essary to maintain this data

In fact, many popular applications are now using XML as an alternative

to previously proprietary layouts Microsoft Office is a great example:

You can now save Word and Excel documents in XML Take a look at thefollowing XML fragment, which was created when I built and saved avery simple spreadsheet:

⻬ Information interchange: Whether or not you much like XML, you may

not even have a choice about whether or not to use it For example,many organizations interchange data with other enterprises In anincreasing number of cases, this information exchange follows rigidspecifications, which are often XML-based

⻬ Industry standards: From automotive to zoology, many industry and

trade associations have based data storage and communication dards on an XML underpinning If your enterprise wants to work withinformation feeds that are built on these guidelines, you need to incor-porate XML into your plans

stan-Placing XML into Your SQL Server

2005 Express Database

In this section, you take a look at the interaction between SQL Server 2005Express and XML First, because XML is a built-in data type, you can use itanywhere within the database, Transact-SQL, or any of the supported

323

Chapter 21: Using XML with SQL Server 2005 Express

Trang 5

Common Language Runtime (CLR) languages You are faced, however, with a2GB limitation for any particular XML document To find out more about inte-grating CLR with SQL Server 2005 Express, check out Chapter 16.

In this section, I show how to leverage the XML storage capabilities of SQLServer 2005 Express Before I begin, remember that I keep the examples asstraightforward and basic as possible You can perform some extremelysophisticated data manipulations, using XML, but starting with a solid foun-dation is a good idea before attempting more advanced operations Theseexamples highlight an application that tracks shipment and part information

To get started, just follow these steps:

1 Launch your favorite SQL editor, and connect to your database server and database.

I use SQL Server Management Studio Express, provided by Microsoft viafree download

2 Decide if you want to create or use an XML schema collection.

In this case, I’ve chosen to create a new XML schema collection, whichcreates an element known as parts, which itself contains elementsknown as code, name, and price It also cites that a given part can have

an unlimited number of these nested elements:

CREATE XML SCHEMA COLLECTION Parts ASN’<?xml version=”1.0” encoding=”UTF-16”?>

<xsd:schemaxmlns:xsd=”http://www.w3.org/2001/XMLSchema”>

<xsd:element name=”parts”>

<xsd:complexType>

<xsd:choice minOccurs=”0” maxOccurs=”unbounded” >

<xsd:sequence>

<xsd:element name=”code” type=”xsd:string”/>

<xsd:element name=”name” type=”xsd:string”/>

<xsd:element name=”price” type=”xsd:decimal”/>

it with relevant objects

3 Design and create your table.

Here’s an example of a table:

324 Part VI: Creating SQL Server 2005 Express Applications

Trang 6

CREATE TABLE Shipments(

ShipmentID INTEGER PRIMARY KEY NOT NULL,ShipmentDate DATETIME NOT NULL,

ShippedParts XML)

If you’ve created an XML schema, you can simply reference it as part ofthe table creation logic If I wanted to associate this table with the XMLschema collection that I created earlier, all that’s necessary is to slightlyalter the table definition:

CREATE TABLE Shipments(

ShipmentID INTEGER PRIMARY KEY NOT NULL,ShipmentDate DATETIME NOT NULL,

ShippedParts XML (Parts))

You can create indexes on XML columns You have two types of indexes

at your disposal: primary and secondary A primary index shreds, or

dis-assembles, the XML data that is normally stored in binary large object(BLOB) format, making information quicker to find With the primary index

in place, you may then create three distinct types of secondary indexes

• PATH: This contains the Path ID and Value columns from the

pri-mary XML index

• PROPERTY: This is made up of the primary key from the

underly-ing table, concatenated with the Path ID and Value columns fromthe primary XML index

• VALUE: This index is the mirror image of the PATH index It

con-tains the Value and Path ID columns

The SQL Server 2005 Express query optimizer chooses the proper ondary index based on the query criteria

sec-4 Insert data into your table.

Here’s an example of creating a single row with two XML entries

Normally, this kind of relationship would require you to separate the lineitem entries into their own table, because it has two entities:

INSERT INTO Shipments VALUES(1,’<Root>

<Parts OrderID=”1” PurchaseOrderNumber=”NSSDJS#1”>

Trang 7

Operating on XML-based Information

After you have XML-based data residing in your SQL Server 2005 Expressdatabase (the subject of the preceding section), the next logical step is tomake use of it Stay tuned — that’s the subject of this section

As with many other SQL Server 2005 Express technologies, you can take ous paths when working with XML data To keep these examples as straight-forward as possible, I explore a limited subset of these options In particular, Isteer away from the potentially confusing subject of namespaces I also useuntyped XML to reduce visual clutter

vari-To help you locate and modify XML-based information, five data functions are at your disposal Table 21-1 highlights these methods, along with theirpurposes

value() Convert XML-formatted information into standard SQL style

For the balance of this chapter, I show you how to use these methods toachieve your goals I continually refer to the Shipments table that I lay out in

326 Part VI: Creating SQL Server 2005 Express Applications

Trang 8

the “Placing XML into Your SQL Server 2005 Express Database” section, lier in this chapter.

ear-Searching for XML data

In this first example, I’m running a basic search against the table, using thequery()method from the XML ShippedParts column Notice that I com-bine a standard WHERE clause with this method:

SELECT ShippedParts.query(‘/Root/Parts/DeliveryDate’)FROM Shipments

WHERE ShipmentID = 1

This query retrieves the DeliveryDate element To get a list of all the items

in the document, here’s how the query looks:

SELECT ShippedParts.query(‘/Root/Parts/Items’)FROM Shipments

Using the exist() method, you can easily create a query that inspects theXML data and looks for matches:

SELECT ShippedParts.query(‘/Root/Parts/Items/LineItem’)FROM Shipments

In the preceding example, I’m converting the shipment weight element fromthe ShippedParts XML column into a decimal(6,2)

If you want to cut to the chase and just issue plain old SELECT statements,you must know how SQL Server Management Studio Express displays thisinformation Just click any column that contains XML, and you see somethinglike what’s shown in Figure 21-3

327

Chapter 21: Using XML with SQL Server 2005 Express

Trang 9

Modifying XML dataLooking at all this nifty XML information is nice, but how easy can you makealterations? Amending data is actually quite easy Here’s a statement thatuses the combination of the modify() method and the replace statementand changes the purchase order number attribute:

UPDATE ShipmentsSET ShippedParts.modify(‘

replace value of (/Root/Parts/@PurchaseOrderNumber)[1]with “TVC-15 PR1DA”

‘)WHERE ShipmentID = 1

The modify() method expects you to provide a string that conforms to theXML Data Manipulation Language (XML DML) XML DML extends the stan-dard XQuery language, making data alterations easier to undertake

When deleting records, you can use the delete statement from within themodify()method Here’s an example of removing the second line item entryfrom within the Items node:

UPDATE ShipmentsSET ShippedParts.modify(‘delete /Root/Parts/Items/*[2]’)WHERE ShipmentId = 1

Formatting relational data as XMLWhat should you do if all your data is locked up in a relational format, yet youwant to work with it in an XML format? This is actually quite simple, as I now

Figure 21-3:

XML data inSQL ServerManagementStudio

328 Part VI: Creating SQL Server 2005 Express Applications

Trang 10

show you For the purposes of this example, suppose that you track tion about shipping vendors in two important tables The first table, Shippers,holds details about each vendor The second table, ShippingLocations,stores information about each location supported by your vendors In the nexttwo sample queries, I ask SQL Server 2005 Express to provide a list of all loca-tions for each shipper.

informa-By using the FOR XML directive, you can instruct SQL Server 2005 Express toconvert the output from a given query into XML In this first example, I usethe RAW directive to create basic XML output:

SELECT Shippers.ShipperName,

ShipperLocations.LocationNameFROM Shippers, ShipperLocationsWHERE Shippers.ShipperID = ShipperLocations.ShipperIDORDER BY ShipperName

FOR XML RAW

By using RAW, I’ve asked SQL Server 2005 Express to create generic, nested rows that are prefixed with row:

non-<row ShipperName=”Federales Pesadillas SA de CV” LocationName=”El Paso” />

<row ShipperName=”Federales Pesadillas SA de CV” LocationName=”Phoenix” />

<row ShipperName=”Federales Pesadillas SA de CV” LocationName=”Los Angeles” />

<row ShipperName=”No Questions Asked Delivery” LocationName=”Jersey City” />

<row ShipperName=”No Questions Asked Delivery” LocationName=”Brooklyn” />

<row ShipperName=”No Questions Asked Delivery” LocationName=”Phoenix” />

<row ShipperName=”No Questions Asked Delivery” LocationName=”Fresno” />

<row ShipperName=”Sumimasen Shipping” LocationName=”Seattle” />

<row ShipperName=”Sumimasen Shipping” LocationName=”Phoenix” />

<row ShipperName=”Sumimasen Shipping” LocationName=”Los Angeles” />

<row ShipperName=”Two Guys and a Truck” LocationName=”Brooklyn” />

<row ShipperName=”Two Guys and a Truck” LocationName=”Jersey City” />

<row ShipperName=”Two Guys and a Truck” LocationName=”Bronx” />

Things get more interesting with the AUTO directive, which returns its results

in a simple tree:

SELECT Shippers.ShipperName,

ShipperLocations.LocationNameFROM Shippers, ShipperLocationsWHERE Shippers.ShipperID = ShipperLocations.ShipperIDORDER BY ShipperName

FOR XML AUTO

<Shippers ShipperName=”Federales Pesadillas SA de CV”>

<ShipperLocations LocationName=”El Paso” />

329

Chapter 21: Using XML with SQL Server 2005 Express

Trang 11

<ShipperLocations LocationName=”Los Angeles” />

</Shippers>

<Shippers ShipperName=”No Questions Asked Delivery”>

<ShipperLocations LocationName=”Jersey City” />

struc-of the tree to producing an XML schema to handling binary information

330 Part VI: Creating SQL Server 2005 Express Applications

Trang 12

Part VII

The Part of Tens

Trang 13

In this part

SQL Server 2005 Express is a great choice for a base platform It combines entry-level simplicity andprice with the power and capabilities of an industrial-strength database engine And given the broad reach ofMicrosoft’s technologies, a wealth of information is outthere about how to make the most of this product

data-To begin, I give ten places you can go to get more helpabout SQL Server 2005 Express Next, even though yourSQL Server 2005 Express experience should go smoothly,you may get befuddled or things can go wrong To helpyou get over these obstacles, I catalog ten of the mostbeneficial troubleshooting tips

Trang 14

Chapter 22

Ten Sources of Information on SQL Server 2005 Express

In This Chapter

䊳Microsoft SQL Server Web site

䊳Microsoft Developer Network

䊳Wikipedia, newsgroups, and user groups

䊳Magazines and books

䊳Design, administrative, and database generation tools

As you embark on your SQL Server 2005 Express journey, you can takecomfort in the fact that there are many others on the same path In thischapter, I show you how to leverage some of the abundant resources pro-vided by your fellow SQL Server devotees to help make your trip smoother

Microsoft SQL Server Web Site

Here’s a great place to get started finding more about SQL Server 2005 Express.Aside from the usual market-speak, you find a variety of valuable product andtechnical details that you can use to further your understanding of not only SQLServer 2005 Express, but all the available database editions You can find it here:

www.microsoft.com/sql/default.mspx

Trang 15

Microsoft Developer Network

In an effort to support software developers, Microsoft offers a comprehensiveset of services known as the Microsoft Developer Network In addition to thebroad suite of software available for purchase, an extremely content-rich Website is available to anyone, whether or not they are a subscriber It containswhite papers, technical briefs, and a deep knowledge base that you cansearch to get answers to your questions You find it here:

Internet-http://en.wikipedia.org/wiki/Database_normalization

Newsgroups

These collaborative spaces are an immense help when you’re struggling with

a technical problem Chances are that someone can address your question Inthe past few years, Google has done a great job helping to organize andrescue Usenet It’s easier than ever to access these groups via your browser.Here’s a link to 27 (at last count) newsgroups focused solely on SQL Server:

334 Part VII: The Part of Tens

Trang 16

Several well-written magazines are available that provide significant coverage

of database topics Some are database-agnostic, while others focus cally on this product These periodicals include

On the other hand, if you want to meet and greet your counterparts face, chances are that an Internet search can point you toward a good candi-date user group not too far from you

face-to-Books

While this book helps you get started with SQL Server 2005 Express, manyother titles can give you a broader understanding of building high-qualitydatabase applications Try looking for well-regarded books that cover any ofthese topics; they are all pertinent in the context of SQL Server 2005 Express:

⻬ Relational database design theory and practice

⻬ Best practices for user interface design

⻬ Distributed computing

335

Chapter 22: Ten Sources of Information on SQL Server 2005 Express

Trang 17

Database Design Tools

If you’re building a simple application, chances are that you won’t need toperform any extensive database design and modeling to realize your goals.However, if you face a more daunting task, you’re wise to look into special-ized tools that focus on this portion of the application development lifecycle.Embarcadero Technologies makes a collection of products that add valuethroughout the entire process You find them here:

www.embarcadero.com/products/products.html

Administrative Tools

As I’ve shown throughout the book, SQL Server Management Studio is a greattool for administering your SQL Server 2005 Express database However, youmay also be interested in one of the third-party tools out there I’ve usedTOAD for SQL Server by Quest Software; all the major database platformshave versions of this product You can find it here:

www.toadsoft.com/toadsqlserver/toad_sqlserver.htm

Data Generation Tools

Generating sample data by hand is one of the more tedious tasks you facewhen building and testing an application for your SQL Server 2005 Expressinstallation Fortunately, tools on the market can automate this for you, free-ing you up to spend your time developing and then tuning your application.I’ve had great success with the DTM Data Generator, which you find here:

www.sqledit.com/dg/index.html

Blogs

There are some great blogs out there that offer a broad range of informationabout SQL Server You’ll even find postings from the Microsoft product devel-opment teams Check out the blogs at technet.com and msdn.com:

http://blogs.technet.com

http://blogs.msdn.com

336 Part VII: The Part of Tens

Trang 18

Chapter 23

Ten SQL Server 2005 Express

Troubleshooting Tips

In This Chapter

䊳Getting a copy of SQL Server 2005 Express

䊳Solving installation, connection, and administration problems

䊳Mastering security difficulties

䊳Resolving data inconsistencies

䊳Setting up automated operations

䊳Simplifying complicated data structures

䊳Developing high quality software

䊳Speeding up a sluggish server

As an entry-level database server that is built on the same platform asthe entire SQL Server product family, SQL Server 2005 Express com-bines simplicity with great power and a massive set of features Naturally, allthese capabilities can a bit confusing at times, so this chapter is dedicated tohelping you rise above some of the most common predicaments that youlikely encounter

Show Me How I Can Get the Product

If you’re ready to get started with SQL Server 2005 Express, all you need to do

is follow one of the following two paths:

⻬ Check out Microsoft’s Web site You find a handy download link for SQL

Server at www.microsoft.com/sql

⻬ Use the enclosed CD To make things even easier, a copy of SQL Server

2005 Express is on the CD that comes with this book Simply insert the disc

in your CD drive, and follow the on-screen instructions You’ll be off andrunning in no time (Appendix D contains more information about the CD.)

Trang 19

I Can’t Install It!

Having some cool new software and not being able to get it installed is notmuch fun Luckily, SQL Server 2005 Express usually installs without a hitch Ifyou do encounter an obstacle, use the following checklist to help get you out

of hot water:

1 Make sure you have sufficient permissions to add or remove software.

In general, installing or removing software as an administrator is a goodidea Otherwise, the operating system may block you from making thesekinds of changes

2 Remove any previous versions of SQL Server 2005 Express via the Add/Remove Programs application within the Control Panel.

If you skip this step, the installer probably complains loudly and thenkeels over Even though it’s tedious, take the time to clean things upbefore trying to install

3 Download and deploy the Windows Installer.

If you’re running a more modern version of Windows, you likely alreadyhave the installer on your system

4 Download and install the Microsoft NET Framework 2.0.

SQL Server 2005 Express is built upon this framework; if it’s missing, youcan’t install the database

If you want more ideas about how to have a good installation experience,have a look at Chapter 2

I Can’t Connect to the Database!

Connection problems are one of the most common complaints about anydatabase server, SQL Server 2005 Express included Happily, you can usuallyovercome these complications without too much difficulty If you can’t con-nect, try one of these remedies:

⻬ Make sure the database server is running: Unless you request that the

SQL Server 2005 Express service launch when your system boots, yousimply need to start the service Chapter 2 tells you all about kicking offthe SQL Server 2005 Express service

⻬ Make sure that you’re using the right protocol: You can use several

communications methods to communicate with SQL Server 2005Express In order to successfully converse with the database server, youneed to make sure that both the client and server are speaking on the

338 Part VII: The Part of Tens

Trang 20

right channel with the right setup In particular — because SQL Server

2005 Express defaults to local connections only — if you want remoteaccess, you must run the SQL Server Surface Area Configuration tool toallow both local and remote connections You can also choose the proto-col for these conversations Chapter 3 reveals all that you need to know

to get the dialogue going

⻬ Adjust your connection string: When you connect to SQL Server 2005

Express, you need to specify a connection string that helps locate thedatabase server Often highly site-specific, even the smallest error in thisconnection string dooms your conversation from the start Chapter 4has all the details about the various flavors of connection string thatyou’re likely to encounter

Show Me How to Administer

My Database

Even though SQL Server 2005 Express is an entry-level database that doesn’trequire much care and feeding, you still need to periodically handle adminis-trative tasks Here are two good choices to get the job done quickly and easily:

⻬ SQLCMD utility: This character-based tool ships with every copy of SQL

Server 2005 Express You can run just about any administrative task byusing direct Transact-SQL or one of the hundreds of built-in systemstored procedures

⻬ SQL Server Management Studio Express Edition: If you have more of a

hankering for graphical tools, you want to look at this utility While a featured version ships with the more extensive SQL Server editions, eventhis entry-level version available for SQL Server 2005 Express lets you per-form many administrative chores And whatever isn’t possible, you canalways handle with direct Transact-SQL or system stored procedures

full-I Can’t See My Data!

If you can’t seem to locate information that you know is in your database,don’t despair: Unless someone has inadvertently deleted data, it’s likely stillpatiently waiting inside your database In many cases, difficulties like this onereally are symptoms of an underlying permission problem

Because it’s built on the enterprise-class SQL Server database platform, SQLServer 2005 Express offers all the security capabilities of its bigger siblings

Unfortunately, all this power can sometimes translate into unforeseen security

339

Chapter 23: Ten SQL Server 2005 Express Troubleshooting Tips

Trang 21

obstacles These aren’t hard to overcome, but you do need to know how tocorrectly configure your permissions Check out Chapter 11 to get a handle

on all that you can do with security in SQL Server 2005 Express

My Data Is Messed Up!

Unless you believe in gremlins or other supernatural entities that descendout of the ether and wreak havoc on your data, chances are that any informa-tion problems are due to one of a relatively small number of errors and omis-sions Here’s what to watch out for:

⻬ Referential integrity issues: To help keep all your data synchronized,

SQL Server 2005 Express offers referential integrity features These vent you or your applications from inadvertently altering rows from onetable without making corresponding changes in another table To get abetter idea of how to use referential integrity to your advantage, take alook at Chapter 8

pre-⻬ Failure to use transactions: Transactions help certify that your

data-base interactions happen in logically consistent groups Without propertransactions, an operation may update one table but fail to do the samefor other tables The result is damaged data integrity Chapter 12 isdesigned to help you make the most of transactions

⻬ Incorrectly defined columns: Believe it or not, sometimes database

designers choose the wrong kind of data type when setting up theirtables For example, a particular field may need to contain currencyamounts, which include decimals Yet when they write the SQL to createthe table, they choose the INTEGER data type for this column This datatype means that SQL Server 2005 Express discards any fractionalamounts from that column

Another common problem sees database designers not providingenough space for character-based fields Again, SQL Server 2005 Expresscheerfully tosses away any extra data, leading to damaged informationand unhappy users

I Want to Automate Some Operations

SQL Server 2005 Express offers two very helpful features that you can use tohelp streamline common database tasks:

⻬ Stored procedures and functions Stored procedures and functions are

bits of logically grouped application software that you can write in avariety of programming languages, including Transact-SQL, Visual Basic,

340 Part VII: The Part of Tens

Ngày đăng: 08/08/2014, 22:20

TỪ KHÓA LIÊN QUAN