100% found this document useful (1 vote)
20 views

Microsoft SQL Server 2005 Express Edition for Dummies Robert Schneider download

The document provides information about the book 'Microsoft SQL Server 2005 Express Edition For Dummies' by Robert Schneider, which is available for download in various formats. It includes details on the book's content, structure, and the author's background, as well as acknowledgments and copyright information. The book aims to guide users through the installation, administration, and programming aspects of SQL Server 2005 Express.

Uploaded by

dhuysadelfo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
20 views

Microsoft SQL Server 2005 Express Edition for Dummies Robert Schneider download

The document provides information about the book 'Microsoft SQL Server 2005 Express Edition For Dummies' by Robert Schneider, which is available for download in various formats. It includes details on the book's content, structure, and the author's background, as well as acknowledgments and copyright information. The book aims to guide users through the installation, administration, and programming aspects of SQL Server 2005 Express.

Uploaded by

dhuysadelfo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 75

Microsoft SQL Server 2005 Express Edition for

Dummies Robert Schneider pdf download

https://ebookgate.com/product/microsoft-sql-server-2005-express-
edition-for-dummies-robert-schneider/

Get Instant Ebook Downloads – Browse at https://ebookgate.com


Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...

Microsoft SQL Server 2005 Express Edition for dummies


Robert D Schneider

https://ebookgate.com/product/microsoft-sql-server-2005-express-
edition-for-dummies-robert-d-schneider/

ebookgate.com

Beginning Microsoft SQL Server 2008 Programming Robert


Vieira

https://ebookgate.com/product/beginning-microsoft-sql-
server-2008-programming-robert-vieira/

ebookgate.com

Microsoft SQL Server 2008 R2 Unleashed Rankins

https://ebookgate.com/product/microsoft-sql-server-2008-r2-unleashed-
rankins/

ebookgate.com

Microsoft SQL Server 2008 Bible 1st ed Edition Paul


Nielsen

https://ebookgate.com/product/microsoft-sql-server-2008-bible-1st-ed-
edition-paul-nielsen/

ebookgate.com
Microsoft Visual C 2005 Express Edition Build a Program
Now Patrice Pelland

https://ebookgate.com/product/microsoft-visual-c-2005-express-edition-
build-a-program-now-patrice-pelland/

ebookgate.com

Microsoft Visual Basic 2005 Express Edition Build a


Program Now Patrice Pelland

https://ebookgate.com/product/microsoft-visual-basic-2005-express-
edition-build-a-program-now-patrice-pelland/

ebookgate.com

Professional Microsoft SQL Server 2012 Reporting Services


1., Auflage Edition Bruckner

https://ebookgate.com/product/professional-microsoft-sql-
server-2012-reporting-services-1-auflage-edition-bruckner/

ebookgate.com

Professional Microsoft SQL Server 2012 Reporting Services


1st Edition Paul Turley

https://ebookgate.com/product/professional-microsoft-sql-
server-2012-reporting-services-1st-edition-paul-turley/

ebookgate.com

Accelerated SQL Server 2008 1st Edition Robert E. Walters

https://ebookgate.com/product/accelerated-sql-server-2008-1st-edition-
robert-e-walters/

ebookgate.com
Microsoft ®


SQL Server 2005
Express Edition
FOR

DUMmIES

by Robert Schneider
Microsoft ®


SQL Server 2005
Express Edition
FOR

DUMmIES

by Robert Schneider
Microsoft® SQL Server™ 2005 Express Edition For Dummies®
Published by
Wiley Publishing, Inc.
111 River Street
Hoboken, NJ 07030-5774
www.wiley.com
Copyright © 2006 by Wiley Publishing, Inc., Indianapolis, Indiana
Published by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or
by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permit-
ted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written
permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the
Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600.
Requests to the Publisher for permission should be addressed to the Legal Department, Wiley Publishing,
Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4355, or online at
http://www.wiley.com/go/permissions.
Trademarks: Wiley, the Wiley Publishing logo, For Dummies, the Dummies Man logo, A Reference for the
Rest of Us!, The Dummies Way, Dummies Daily, The Fun and Easy Way, Dummies.com, and related trade
dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates in the United
States and other countries, and may not be used without written permission. Microsoft and SQL Server
are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other coun-
tries. All other trademarks are the property of their respective owners. Wiley Publishing, Inc., is not asso-
ciated with any product or vendor mentioned in this book.
‘Microsoft’ is a registered trademark of Microsoft Corporation in the United States and/or other countries
and is used by Wiley Publishing, Inc. under license from owner. ‘Microsoft® SQL Server™ 2005 Express
Edition For Dummies®’ is an independent publication not affiliated with Microsoft Corporation.

LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NO REP-
RESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CON-
TENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT
LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE CRE-
ATED OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS. THE ADVICE AND STRATEGIES CON-
TAINED HEREIN MAY NOT BE SUITABLE FOR EVERY SITUATION. THIS WORK IS SOLD WITH THE
UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, OR
OTHER PROFESSIONAL SERVICES. IF PROFESSIONAL ASSISTANCE IS REQUIRED, THE SERVICES OF A
COMPETENT PROFESSIONAL PERSON SHOULD BE SOUGHT. NEITHER THE PUBLISHER NOR THE
AUTHOR SHALL BE LIABLE FOR DAMAGES ARISING HEREFROM. THE FACT THAT AN ORGANIZATION
OR WEBSITE IS REFERRED TO IN THIS WORK AS A CITATION AND/OR A POTENTIAL SOURCE OF FUR-
THER INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSES THE INFOR-
MATION THE ORGANIZATION OR WEBSITE MAY PROVIDE OR RECOMMENDATIONS IT MAY MAKE.
FURTHER, READERS SHOULD BE AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK MAY HAVE
CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT IS READ.

For general information on our other products and services, please contact our Customer Care
Department within the U.S. at 800-762-2974, outside the U.S. at 317-572-3993, or fax 317-572-4002.
For technical support, please visit www.wiley.com/techsupport.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may
not be available in electronic books.
Library of Congress Control Number: 2005927727
ISBN-13: 978-0-7645-9927-9
ISBN-10: 0-7645-9927-5
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
1B/QW/QW/QW/IN
About the Author
Robert D. Schneider has more than 15 years of experience developing and
delivering sophisticated software solutions worldwide. He has provided data-
base optimization, distributed computing, and other technical expertise to a
wide variety of enterprises in the financial, technology, and government sec-
tors. Clients have included Chase Manhattan Bank, VISA, HP, SWIFT, and the
governments of the United States, Brazil, and Malaysia.

He is the author of Optimizing Informix Applications, Microsoft SQL Server:


Planning and Building a High Performance Database, and MySQL Database Design
and Tuning. He has also written numerous articles on technical and professional
services topics. He can be reached at Robert.Schneider@Think88.com.
Dedication
In memory of Saul Weiss.

Author’s Acknowledgments
The author wants to acknowledge the following people for their invaluable
assistance in creating and publishing this work: Nicole Sholly, Tiffany
Franklin, Damir Bersinic, Rebecca Senninger, Terri Varveris, Nancy L.
Reinhardt, and the folks in Composition Services. And last but certainly not
least: Lynn Z. Schneider, Danielle Jolie Schneider, and Nicole Sierra Schneider
for their unswerving support and encouragement.
Publisher’s Acknowledgments
We’re proud of this book; please send us your comments through our online registration form
located at www.dummies.com/register/.
Some of the people who helped bring this book to market include the following:

Acquisitions, Editorial, and Composition Services


Media Development Project Coordinators: Maridee Ennis,
Project Editor: Nicole Sholly Erin Smith
Acquisitions Editor: Tiffany Franklin Layout and Graphics: Carl Byers, Andrea Dahl,
Copy Editor: Rebecca Senninger Stephanie D. Jumper, Lynsey Osborn

Technical Editor: Damir Bersinic Proofreaders: Laura Albert, Techbooks

Editorial Manager: Kevin Kirschner Indexer: Techbooks

Media Development Specialist: Kate Jenkins


Media Development Coordinator:
Laura Atkinson
Media Project Supervisor: Laura Moss
Media Development Manager:
Laura VanWinkle
Editorial Assistant: Amanda Foxworth
Cartoons: Rich Tennant
(www.the5thwave.com)

Publishing and Editorial for Technology Dummies


Richard Swadley, Vice President and Executive Group Publisher
Andy Cummings, Vice President and Publisher
Mary Bednarek, Executive Acquisitions Director
Mary C. Corder, Editorial Director
Publishing for Consumer Dummies
Diane Graves Steele, Vice President and Publisher
Joyce Pepple, Acquisitions Director
Composition Services
Gerry Fahey, Vice President of Production Services
Debbie Stailey, Director of Composition Services
Table of Contents
Introduction..................................................................1
About This Book...............................................................................................1
Foolish Assumptions .......................................................................................1
Conventions Used in This Book .....................................................................2
What You Don’t Have to Read ........................................................................2
How This Book Is Organized...........................................................................3
Part I: Welcome to SQL Server 2005 Express ......................................3
Part II: Administering a SQL Server 2005 Express System ................3
Part III: Adding and Accessing a SQL Server 2005
Express Database................................................................................3
Part IV: Keeping Your Data Safe from Harm ........................................4
Part V: Putting the Tools to Work: Programming
with SQL Server 2005 Express...........................................................4
Part VI: Creating SQL Server 2005 Express Applications ..................4
Part VII: The Part of Tens ......................................................................4
Part VIII: Appendixes .............................................................................5
Icons Used in This Book..................................................................................5
Where to Go from Here....................................................................................6

Part I: Welcome to SQL Server 2005 Express ...................7


Chapter 1: SQL Server 2005 Express Overview . . . . . . . . . . . . . . . . . . . .9
Jumping on Board the SQL Server Express ..................................................9
The SQL Server 2005 Express Environment ...............................................12
Where Does SQL Server Express 2005 Work Best? ....................................15
Small office/Home office (SOHO) .......................................................15
Distributed enterprise .........................................................................16
Independent Systems Vendor/Original Equipment
Manufacturer (ISV/OEM) .................................................................17
Getting Down to Business with SQL Server 2005 Express ........................17
Planning your database .......................................................................18
Building SQL Server 2005 Express applications ...............................19
Configuring, managing, and monitoring
SQL Server 2005 Express .................................................................20

Chapter 2: Downloading and Installing SQL Server 2005 Express


on Your Computer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23
Getting a Copy of SQL Server 2005 Express................................................23
Before You Install ...........................................................................................25
Installing SQL Server 2005 Express..............................................................26
Testing Your Installation ...............................................................................31
viii Microsoft SQL Server 2005 Express Edition For Dummies

Chapter 3: Setting Up SQL Server Express . . . . . . . . . . . . . . . . . . . . . . .35


Points to Ponder During Installation ...........................................................35
Keeping a Low Profile ....................................................................................36
Configuring surface area for services and connections..................36
Configuring surface area for features ................................................38
Is Anyone Out There? ....................................................................................39
Connecting to Your Server............................................................................43
Connecting with SQLCMD ...................................................................43
Connecting with SQL Server Management Studio Express.............44
Connecting with ODBC ........................................................................46
Connecting with Visual Studio Express .............................................49

Part II: Administering a SQL Server 2005


Express System............................................................53
Chapter 4: Putting SQL Server 2005 Express to Work . . . . . . . . . . . . . .55
Planning For Tomorrow as Well as Today...................................................55
Estimating database usage and growth.............................................56
Deciding when to graduate .................................................................56
Administering Your SQL Server 2005 Express System ..............................58
Using character-based utilities...........................................................59
Using SQL Server Management Studio Express ...............................60
Using third-party database administration tools .............................60
Creating a Database and Table .....................................................................60

Chapter 5: Maintaining a SQL Server 2005 Express System . . . . . . . .69


Master of the Database Domain ...................................................................69
Setting SQL Server 2005 Express Parameters.............................................70
How to configure your server.............................................................70
Common server parameters ...............................................................72
Picking Up the Pace .......................................................................................74
Monitoring performance .....................................................................75
Enhancing your computer...................................................................79
Speeding up the database ...................................................................81

Chapter 6: Distributing Your Data with Replication . . . . . . . . . . . . . . .83


Determining When and Why to Replicate ...................................................84
Discovering the Types of Replication..........................................................85
Understanding Replication Limitations ......................................................85
Replication Concepts.....................................................................................86
Components for publishing ................................................................86
Components for subscribing ..............................................................87
Setting Up Replication ...................................................................................87
Table of Contents ix
Part III: Adding and Accessing a SQL Server 2005
Express Database ........................................................91
Chapter 7: Planning Your Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . .93
What Can You Store in a Database? .............................................................93
Designing Your Database ..............................................................................96
Logical design .......................................................................................96
Physical design .....................................................................................97
Using Database Diagram Tools in SQL Server Management
Studio Express ............................................................................................98
Normalization ...............................................................................................100
First normal form................................................................................100
Second normal form...........................................................................101
Third normal form..............................................................................103
When not to normalize ......................................................................104

Chapter 8: Creating Databases, Tables, and Relationships . . . . . . . .107


Using SQL Server Management Studio Express .......................................108
The Object Explorer...........................................................................108
The Query window.............................................................................110
Creating Key Database Objects ..................................................................111
Databases ............................................................................................111
Tables...................................................................................................113
Relationships ......................................................................................119
Enforcing relationships......................................................................120
Constraints..........................................................................................120
Creating a relationship ......................................................................121
Changing or removing a relationship...............................................123

Chapter 9: Talking to a SQL Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . .125


What Is Transact-SQL?.................................................................................125
SQL: The start of it all ........................................................................126
Transact-SQL: SQL on steroids .........................................................126
Accessing Information.................................................................................127
Storing Information in Your Database .......................................................131
Bulk Inserts ...................................................................................................134
The BULK INSERT statement ............................................................134
The bcp utility ....................................................................................135
Format file ...........................................................................................135
Finding Information in Your Database.......................................................136
The SELECT statement ......................................................................136
Filtering your results..........................................................................138
Sorting your results............................................................................140
Built-in functions ................................................................................140
Renaming output columns ................................................................142
Joining tables ......................................................................................142
Subqueries...........................................................................................145
Speeding up your queries .................................................................146
x Microsoft SQL Server 2005 Express Edition For Dummies

Changing Data...............................................................................................150
Deleting Data.................................................................................................152
Removing all rows from a table ........................................................153
Removing some of the rows from a table........................................154

Chapter 10: Transact-SQL: Beyond the Basics . . . . . . . . . . . . . . . . . . .157


Advanced Data Definition ...........................................................................157
Constraints..........................................................................................157
Views ....................................................................................................161
Using XML ...........................................................................................165
Indexing .........................................................................................................168
Deciding what to index ......................................................................168
Creating an index................................................................................169
Searching, Grouping, and Summarizing Data ...........................................170
GROUP BY ...........................................................................................171
ROLLUP................................................................................................172
CUBE ....................................................................................................172
HAVING ................................................................................................173
TIMESTAMP.........................................................................................173

Part IV: Keeping Your Data Safe from Harm ................175


Chapter 11: Securing Your Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .177
Why Bother with Security? .........................................................................177
Insufficient security: When bad things happen to good data.......178
Should you secure your database? ..................................................178
What Can You Secure? .................................................................................178
Who Can You Let Use Your Database? ......................................................180
What Can You Let Users Do? ......................................................................181
Who gets to use the database? .........................................................181
Choosing from the permissions menu.............................................183
Implementing Security.................................................................................183
Getting a list of authorized users .....................................................183
Granting access ..................................................................................185
Setting permissions by securable ....................................................189
Modifying or revoking permissions .................................................190

Chapter 12: Keeping It Together: Using Transactions


to Maintain Data Integrity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .193
What Is Data Integrity? ................................................................................193
Shocking tales of lost integrity .........................................................194
Passing the ACID test.........................................................................194
Key Transaction Structures ........................................................................196
Isolation Levels.............................................................................................196
Using Transactions ......................................................................................198
Table of Contents xi
Chapter 13: Preventing Data Loss . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .201
Transactions: Your Data’s Best Friend ......................................................201
What are transactions?......................................................................202
How do transactions work? ..............................................................202
Synchronizing Memory and Disk Storage .................................................203
Backing Up Your Data: Inexpensive Insurance You Can’t
Afford to Skip! ...........................................................................................204
Choosing the right backup strategy.................................................204
Recovery models................................................................................205
Best practices for protecting your data ..........................................206
Types of backup available in the simple recovery model.............207
Using the simple recovery model to backup your data ................208
Why you should also export information .......................................210
Restoring Data: Time for the Insurance to Pay Off ..................................210

Part V: Putting the Tools to Work: Programming


with SQL Server 2005 Express....................................213
Chapter 14: Using Stored Procedures and Functions . . . . . . . . . . . . .215
Introducing Stored Procedures and Functions ........................................215
Examples of stored procedures and functions...............................217
When not to use a stored procedure or function...........................218
Differences between stored procedures and functions ................219
System stored procedures and functions .......................................219
Getting a list of stored procedures and functions..........................220
Some useful system stored procedures and functions .................221
Writing a Stored Procedure or Function ...................................................223
Using Transact-SQL ............................................................................223
Using the SQL Common Language Runtime (SQLCLR) .................225
Calling a Stored Procedure or Function ....................................................226

Chapter 15: Understanding Triggers . . . . . . . . . . . . . . . . . . . . . . . . . . . .227


Triggers: Actions Awaiting an Event ..........................................................227
Trigger scope ......................................................................................228
Trigger programming languages.......................................................228
How do triggers work?.......................................................................229
Types of Triggers .........................................................................................229
Data Definition Language (DDL) triggers ........................................229
Data Manipulation Language (DML) triggers..................................230
To Trigger, or Not to Trigger? .....................................................................230
Triggers to the rescue! .......................................................................231
Don’t be trigger happy.......................................................................231
Using Triggers...............................................................................................232
Discovering already-existing triggers ..............................................232
Writing new triggers...........................................................................233
Invoking triggers.................................................................................237
xii Microsoft SQL Server 2005 Express Edition For Dummies

Disabling triggers ...............................................................................237


Modifying triggers ..............................................................................238
Deleting triggers .................................................................................239

Chapter 16: Going Beyond Transact-SQL: Using the SQL Common


Language Runtime (SQLCLR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .241
Finding Out How SQLCLR Works................................................................242
The .NET framework ..........................................................................242
Why use SQLCLR? ..............................................................................243
What can you build with SQLCLR?...................................................243
Determining Whether You Should Use SQLCLR .......................................244
Using SQLCLR ...............................................................................................245
Example 1: Customer classification stored procedure..................246
Example 2: Insurance risk function ..................................................248

Chapter 17: Sorry, I’ll Try That Again: Adding Error Handling
to Your Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .251
Don’t Just Ignore It: Why You Should Care About Errors .......................251
How to Handle Errors ..................................................................................252
Information about errors...................................................................252
Built-in system functions...................................................................254
Handling errors in the database .......................................................254
Handling errors in the application ...................................................256
Error Examples .............................................................................................257
Syntax error.........................................................................................258
Database schema issue......................................................................258
Data conversion problems ................................................................259
Referential integrity violation ...........................................................259
Trigger interception ...........................................................................260
Defining Your Own Errors with RAISERROR .............................................260

Chapter 18: Full-Text Searching and Reporting Services . . . . . . . . .263


Deciding to Use the Advanced Services Edition ......................................264
Installation Considerations.........................................................................264
Full-Text Searching.......................................................................................267
Special SQL Server full-text enhancements ....................................268
How full-text search works................................................................269
Using full-text searching ....................................................................270
Full-text predicates versus full-text functions ................................273
Examples .............................................................................................273
Performance tips ................................................................................276
Reporting Services.......................................................................................276
Creating your report ..........................................................................278
Publishing your report ......................................................................284
Maintaining your report ....................................................................286
Table of Contents xiii
Part VI: Creating SQL Server 2005 Express
Applications .............................................................287
Chapter 19: Building a Simple Desktop Application
with Visual Basic Express . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .289
Laying the Groundwork for an Application ..............................................290
Creating a project ...............................................................................290
Creating a new database....................................................................291
Connecting to an existing database .................................................292
Creating new tables............................................................................294
Building the User Interface .........................................................................296
Making Your Program Functional...............................................................298
Adding application logic....................................................................298
Debugging............................................................................................301
Packaging and shipping.....................................................................301

Chapter 20: Building a Simple Web Application


with Visual Web Developer Express . . . . . . . . . . . . . . . . . . . . . . . . . . .303
Laying the Groundwork for an Application ..............................................304
Creating a Web site.............................................................................304
Creating a new database....................................................................306
Connecting to an existing database .................................................307
Creating new tables............................................................................309
Building the User Interface .........................................................................311

Chapter 21: Using XML with SQL Server 2005 Express . . . . . . . . . . .317
What Is This Thing Called XML? ................................................................317
XML advantages .................................................................................318
XML structure .....................................................................................318
Other important XML concepts .......................................................321
When should you use XML?..............................................................322
Placing XML into Your SQL Server 2005 Express Database....................323
Operating on XML-based Information .......................................................326
Searching for XML data .....................................................................327
Modifying XML data ...........................................................................328
Formatting relational data as XML...................................................328

Part VII: The Part of Tens...........................................331


Chapter 22: Ten Sources of Information on
SQL Server 2005 Express . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .333
Microsoft SQL Server Web Site...................................................................333
Microsoft Developer Network ....................................................................334
Wikipedia.......................................................................................................334
Newsgroups ..................................................................................................334
xiv Microsoft SQL Server 2005 Express Edition For Dummies

Magazines......................................................................................................335
User Groups ..................................................................................................335
Books .............................................................................................................335
Database Design Tools ................................................................................336
Administrative Tools ...................................................................................336
Data Generation Tools .................................................................................336
Blogs ..............................................................................................................336

Chapter 23: Ten SQL Server 2005 Express Troubleshooting Tips . . .337
Show Me How I Can Get the Product.........................................................337
I Can’t Install It!.............................................................................................338
I Can’t Connect to the Database! ................................................................338
Show Me How to Administer My Database...............................................339
I Can’t See My Data!......................................................................................339
My Data Is Messed Up!.................................................................................340
I Want to Automate Some Operations .......................................................340
I Want to Simplify My Data ..........................................................................341
I Want to Build Good Software....................................................................341
My Database Server Is Too Slow! ...............................................................342

Part VIII: Appendixes ................................................343


Appendix A: Upgrading to SQL Server 2005 . . . . . . . . . . . . . . . . . . . . .345
Why Migrate? ................................................................................................345
Coming Up with a Good Migration Plan ....................................................346
Delivering on the Migration ........................................................................347

Appendix B: Migrating to SQL Server 2005 Express . . . . . . . . . . . . . .353


Getting Ready to Migrate ............................................................................353
Proper planning prevents poor performance.................................353
Safeguarding your existing information ..........................................354
Completing a Successful Migration............................................................355
Microsoft Access ................................................................................355
Microsoft Data Engine (MSDE) .........................................................360
Text files ..............................................................................................360
Wrapping Up Your Migration ......................................................................361

Appendix C: Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .365

Appendix D: About the CD-ROM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .373


System Requirements ..................................................................................373
What You’ll Find ...........................................................................................374
If You Have Problems (Of the CD Kind).....................................................375

Index........................................................................377
Introduction
A lthough once derided as a provider of relatively low-end relational data-
base products, Microsoft has turned its flagship SQL Server database
into a platform that can compete with any database servers on the market.
Ironically, the downside of all this power is that some now find SQL Server to
be too complex and feature-rich.

In an effort to reclaim the more entry-level segments of the market, Microsoft


has created several different versions of SQL Server. Known as editions, each
of these products addresses a different class of database environment. However,
they’re all built on the same underlying technology platform, which means that
they share many, but not all, of the same features. SQL Server 2005 Express
is the most entry-level of these offerings. Even though Microsoft doesn’t charge
for it, this product has much in common with its more powerful, pricier siblings.

About This Book


This book is designed to help you get productive with SQL Server 2005
Express as quickly as possible. Chances are that you already have enough on
your plate, and wading through reams of database architecture and theory
before figuring out how to use the product just isn’t in the cards.

Here are some of the things you can do with this book:

⻬ Correctly choose the right version of SQL Server.


⻬ Quickly install the product in your environment.
⻬ Rapidly design a database, and then communicate with it.
⻬ Efficiently monitor, maintain, and protect your important data.
⻬ Construct a solid, robust application to work with your information.

Foolish Assumptions
You don’t need a PhD from MIT to derive value from this book. On the contrary:
Any exposure to the items on the following list goes a long way towards helping
2 Microsoft SQL Server 2005 Express Edition For Dummies

you make the most from the book. And if you don’t currently have any experi-
ence, you will soon:

⻬ Relational database management systems (RDBMS): This category


includes products such as Microsoft SQL Server 2000, Oracle, DB2,
Microsoft Access, and so on.
⻬ Relational database design theory: If you’re light in this area, don’t
worry: I show you how to quickly design your own relational database,
as well as some best practices to follow when doing so.
⻬ Structured Query Language (SQL): Even if you’re not familiar with SQL,
or Microsoft’s flavor (Transact-SQL), I show you how to construct
queries and data modification statements.
⻬ Software development tools: During the chapter on building SQL Server
2005 Express-based applications, I make the assumption that you have
some familiarity with modern software development environments. If
you don’t, you can still get some good ideas on how to employ tools
such as Microsoft Visual Basic 2005 Express and Visual Web Developer
2005 Express in partnership with the database server.

Conventions Used in This Book


As you peruse the book, you’ll probably notice several typographical tips
along the way. Designed to help you quickly orient yourself, they include
bold for user entry, monofont for code and other computer output, and italic
for new terms.

What You Don’t Have to Read


You don’t necessarily need to read this book from cover-to-cover, although I
sure hope you want to. The reason that you can skip around is that all the
chapters are designed to stand alone: They don’t require you to build a foun-
dation of knowledge obtained from other chapters.

However, if you’re an absolute newbie with SQL Server who is building a new
application, you’ll probably want to look at the early chapters on the prod-
uct’s architecture and infrastructure first before moving onto the develop-
ment section.

Also, if you’re not the type of person who pops the hood of your car to see
how the motor works, you’ll likely find yourself skipping the information
called out by the tech stuff icons. Just as your car still runs without you mem-
orizing the workings of its transmission, you can still derive a lot of value from
SQL Server 2005 Express even if you don’t know its internal architecture.
Introduction 3
How This Book Is Organized
Microsoft SQL Server 2005 Express Edition For Dummies is split into eight
parts. You don’t have to read it sequentially, and you don’t even have to read
all the sections in any particular chapter. You can use the Table of Contents
and the index to find the information you need and quickly get your answer.
In this section, I briefly describe what you find in each part.

Part I: Welcome to SQL Server


2005 Express
This part introduces you to this entry-level, yet very capable database
server. I review its features and restrictions, and then show you how to
obtain, install, and configure your very own copy. You also see how to deter-
mine the right kind of applications to use with this database, as well as how
to tell when to upgrade to one of the more feature-rich siblings of SQL Server
2005 Express.

Part II: Administering a SQL Server 2005


Express System
Don’t be fooled by the low (actually, free) price point of SQL Server 2005
Express. Aside from a few capacity and feature restrictions, it works exactly
the same as its more powerful siblings. They’ve all been built on the mainline
SQL Server 2005 database platform. However, all this power comes with sig-
nificant administrative responsibilities. Helping you quickly and effectively
perform these managerial tasks is what this part is all about.

Part III: Adding and Accessing a SQL


Server 2005 Express Database
Unless you’re the type of person who installs software just for the pleasure
of it, you’re probably hoping to get some value out of your new SQL Server
2005 Express installation. This part shows you how to create a SQL Server
2005 Express database, and then begin filling it with data. If you’re new to
relational databases, don’t worry: I give you a quick tour of database design
theory and SQL Server’s internal language, Transact-SQL. On the other hand,
if you’re a database wizard, you’ll want to check out the chapter on advanced
Transact-SQL concepts.
4 Microsoft SQL Server 2005 Express Edition For Dummies

Part IV: Keeping Your Data


Safe from Harm
Unfortunately, all sorts of nasty problems can afflict your important informa-
tion, even when it’s safely stored in a database like SQL Server 2005 Express.
Never fear: You have some powerful tools at your disposal. In this part, I
show you how to secure your database from unauthorized manipulation, how
to back up your data, as well as how to use transactions to increase the
integrity of your information and software applications.

Part V: Putting the Tools to Work:


Programming with SQL
Server 2005 Express
You may be using SQL Server 2005 Express in conjunction with pre-built
applications and office productivity tools; you won’t need to do any program-
ming, and you can probably safely skip this part. On the other hand, if you’re
constructing your own solutions, you can derive a lot of value from seeing
how to use stored procedures and functions, interacting with the Common
Language Runtime (CLR), as well as gracefully dealing with any errors that
might arise along the way.

Part VI: Creating SQL Server 2005


Express Applications
SQL Server 2005 Express is tightly coupled with an entire line of easy-to-use
software development technologies from Microsoft. This part shows you how
to quickly get productive with programming tools such as Microsoft Visual
Basic 2005 Express and Visual Web Developer 2005 Express in conjunction
with your new database server. You also find out how to leverage and incor-
porate XML into your SQL Server 2005 Express-based applications.

Part VII: The Part of Tens


I hope that you find this book contains all that you need to get your work
done with SQL Server 2005 Express. However, if you’re interested in finding
out even more about the product, this part contains a list of ten excellent
Introduction 5
resources for additional data. Because problem solving comes with the terri-
tory with any robust software application, you’ll also want to check out the
list of ten troubleshooting tips.

Part VIII: Appendixes


This part begins with two migration appendixes. The first helps you decide
when to upgrade to a higher capacity version of SQL Server, including an
explanation of how to use the excellent Import and Export Wizard to make
the migration a snap. The next appendix looks at migration from the point of
view of uploading data from Microsoft Access and flat files into your SQL
Server 2005 Express database. You also find out how to install the software
from the CD that accompanies the book, as well as get a comprehensive list
of key relevant SQL Server 2005 Express and relational database terms.

Icons Used in This Book


What’s a For Dummies book without icons pointing you in the direction of
really great information that’s sure to help you along your way? In this sec-
tion, I briefly describe each icon I use in this book.

This icon highlights the new features you find in this latest version of SQL
Server Express.

This icon marks a general interesting and useful fact — something that you
may want to remember for later use.

When you see this icon, you know that techie stuff is nearby. If you’re not
feeling very techie, you can skip this info.

The Tip icon points out helpful information that is likely to make your
job easier.

The Warning icon highlights lurking danger. With this icon, I’m telling you to
pay attention and proceed with caution.
6 Microsoft SQL Server 2005 Express Edition For Dummies

Where to Go from Here


To help you navigate quickly, I list here some common tasks, along with
where you can get more details:

Task Look At
Installation requirements and guide Chapter 2
Upgrading to SQL Server 2005 Express Appendix B
Common problems Chapter 23
SQL Server 2005 Express functionality limitations Chapter 1
Converting to a more powerful SQL Server version Appendix A
Pairing the database with the right applications Chapter 1
Enabling the right network protocols Chapter 3
Creating databases and tables Chapter 8
Best practices for database design Chapter 9
Transact-SQL syntax Chapter 10
Using XML with SQL Server 2005 Express Chapter 21
Writing your own stored procedures Chapter 14
Using views Chapter 9
Configuring the SQL Server 2005 Express engine Chapter 5
Integrating transactions to your application Chapter 12
Taking advantage of replication Chapter 6
Using SQL Server Management Studio Express Chapter 4
Intercepting calls to your database Chapter 15
Protecting your information Chapter 11
Backing up your database Chapter 13
Using other languages to build stored procedures Chapter 16
Graceful error handling Chapter 17
Building applications with Express editions Chapters 19 and 20
Reporting services Chapter 18
Key terms and concepts Appendix C
Part I
Welcome to SQL
Server 2005 Express
In this part . . .
B efore you can start making the most of your SQL
Server 2005 Express database server, you need to do
a few simple — yet important — tasks. That’s what this
part is all about: Helping you figure out if SQL Server 2005
Express is right for you, and then getting going as quickly
as possible.

First, you find out all about SQL Server 2005 Express,
including its major features, as well as where it differs
from its bigger (and more expensive) siblings. With that
background out of the way, you’re ready to see how to get
your own, free copy of SQL Server 2005 Express. Next, I
tell you about some common situations in which you use
this product, as well as some scenarios where you should
choose another edition. Finally, the part closes out with
some basic steps that you can follow to get your database
up and running.
Chapter 1

SQL Server 2005 Express


Overview
In This Chapter
䊳 Introducing SQL Server 2005 Express (SSE)
䊳 Determining whether SSE is right for you
䊳 Discovering the features of SSE
䊳 Understanding how SSE works
䊳 Getting going with SQL Server 2005 Express

F rom the developer’s or user’s perspective, SQL Server 2005 Express


strikes a nice balance between price (free) and performance (powerful).
In this chapter, I offer up some insight into this new product.

To begin, I give you some context to understand how this capable, yet entry-
level product came about, along with how it fits in with the rest of the SQL
Server product family. Next, you see who the ideal user is for SQL Server 2005
Express, along with a list of some of the product’s most compelling features
(as well as what’s not present). Finally, I show you the kind of tools that you’ll
want to acquire so you can get started building applications and working
with your SQL Server 2005 Express data.

Jumping on Board the SQL Server Express


Once upon a time, if you wanted to store information on a computer, you had
to write your own low-level, highly specialized program that organized this
data, and also allowed you to update and retrieve the data. This was very
cumbersome, time-consuming, and error-prone. Eventually, a host of special-
ized companies sprang up to provide standardized, industrial-strength prod-
ucts known as databases.

A database is a special kind of software application whose main purpose is


to help people and programs store, organize, and retrieve information. This
10 Part I: Welcome to SQL Server 2005 Express

frees up application developers to focus on the business task at hand, rather


than being responsible for supervising the intricacies of data management.

As more time passed, a new breed of database companies arose. With names
like Oracle, Informix, and Sybase, these vendors (and many others) developed
a particular kind of database, known as a relational database. Relational data-
bases are particularly well designed for storing information in tabular format,
which further helped software developers as they built a whole new class of
enterprise applications.

Microsoft also entered the relational database fray some years back with the
SQL Server database. Once thought of as a relatively lightweight database
vendor, Microsoft has continually refined SQL Server to the point where it
can compete for the largest and most complicated database-driven applica-
tions. Of course, all these capabilities and power have made the SQL Server
database platform somewhat intimidating and confusing for many developers
and users, especially those that are building and using simpler solutions.

To address this problem, beginning with the SQL Server 2005 product family,
Microsoft has created several different versions of SQL Server. Known as edi-
tions, each of these versions addresses a different class of database environ-
ment. Despite this segmentation, all editions are built on the same underlying
technology platform. The main difference among the editions is that the sim-
pler, less far-reaching versions don’t have all the features and storage capac-
ity that you find in their larger (and more complex) siblings. Here’s a list of all
the SQL Server 2005 editions:

⻬ Enterprise: This is the most robust edition of SQL Server 2005. It


includes a host of features that make it a good choice for a 24/7, mission-
critical database server platform. Just a few of these features include
• Advanced business intelligence analytics
• Robust data transformation logic
• High availability capabilities
This product also has two developer-focused versions, which contain all
the Enterprise features but are licensed differently. These are SQL Server
2005 Developer Edition and SQL Server 2005 Evaluation Edition.
⻬ Standard: With much of the feature set of its big brother, this edition is
fine for the vast majority of database applications. The main difference
is that this edition is somewhat lighter in both its business intelligence
and high availability feature sets.
⻬ Workgroup: Aimed at smaller, departmental applications, this
still-powerful edition of SQL Server 2005 introduces some limitations
Chapter 1: SQL Server 2005 Express Overview 11
that are not likely to be issues for these smaller computing environ-
ments. Some of these restrictions include
• Hardware and database size constraints
• Diminished high availability
• Reduced business intelligence
⻬ Express: Now it’s time to look at the star of this show. This is the sim-
plest and easiest to use database offering in the SQL Server 2005 prod-
uct family. On top of that accolade, it’s also free to download and
redistribute (with some licensing restrictions).
This is the right edition for you if any of the following describe you:
• A software developer (seasoned or brand-new) wanting to learn
about relational databases.
• A packaged application provider looking to embed a free, yet
sturdy database with your solution.
• An end user with a lot of information to store, but not a lot of cash
to buy a database.

To get the lowdown on the differences among each SQL Server 2005 edition,
go to

www.microsoft.com/sql/prodinfo/features/compare-
features.mspx

As you evaluate potential uses for SQL Server Express 2005, note that you can
use it for all sorts of applications, from traditional, desktop-based rich client
software as well as browser-based solutions that are available over the Internet.

SQL Server 2005 Express is just one component of a larger collection of entry-
level products aimed at helping developers and hobbyists use Microsoft’s tech-
nologies to deliver powerful and flexible computing solutions. These products,
all of which are part of Visual Studio 2005 Express include the following:

⻬ Visual Web Developer 2005 Express


⻬ Visual Basic 2005 Express
⻬ Visual C# 2005 Express
⻬ Visual C++ 2005 Express
⻬ Visual J# 2005 Express

All these products work seamlessly with SQL Server 2005 Express. If you’re inter-
ested in taking advantage of these products, have a look at Chapters 19 and 20.
12 Part I: Welcome to SQL Server 2005 Express

The SQL Server 2005


Express Environment
Although it’s the most junior member of the family, SQL Server 2005 Express
has more than enough capabilities and power to support the majority of
database-driven applications. You should be aware of these key features —
along with some limitations — as you build your solution:

⻬ Robust technology platform: SQL Server 2005 Express is built on the


same underlying technology platform as all the Microsoft SQL Server
products. This significantly increases this product’s effectiveness and
stability.
⻬ Interoperability and upgradeability: Because SQL Server 2005 Express
is built on the underlying SQL Server 2005 platform, you can easily
develop solutions that work with any SQL Server 2005 edition. In addi-
tion, you can straightforwardly migrate from this entry-level edition to a
more full-featured edition without changing your database design or
altering any application or stored procedure/trigger code.
⻬ Memory: With memory costs dropping significantly over time, many
administrators now stock their computers with large amounts of RAM.
However, regardless of how much memory you have, SQL Server 2005
Express doesn’t take advantage of any more than 1GB of RAM.
⻬ Automatic performance tuning: This is one feature that SQL Server
2005 Express shares with the other database editions. It lightens the
administrative load by automatically updating the database’s configura-
tion based on system activities and other profiling data.
However, no automation can free you from the performance implications
of an inefficient database or application construction: You are still
responsible for designing your database structure and software logic
with speed in mind.
⻬ Database size: This is probably the most significant limitation of SQL
Server 2005 Express, because any given database can’t be bigger than
4GB. Although this limitation won’t be a problem for many applications,
certain data-intensive solutions can test it. Of course, you are free to
have multiple databases that are each 4GB.
⻬ Full security capabilities: Here’s another area where this edition and the
more costly versions of SQL Server 2005 basically have no differences.
This means that you can take advantage of a broad band of security fea-
tures as you go about developing your solutions. These range from
authentication and auditing all the way through public key management
and encryption.
Chapter 1: SQL Server 2005 Express Overview 13
⻬ Multi-processors: Running a computer with more than one central pro-
cessing unit (CPU) is a great way to increase performance and through-
put. However, SQL Server 2005 Express only takes advantage of one CPU,
regardless of how many are available.
⻬ Administrative tools: Microsoft offers the excellent SQL Server
Management Studio Express graphical tool to help you monitor and
manage your database. It’s available for free download from Microsoft’s
Web site.
⻬ Visual Studio integration: Although SQL Server 2005 Express is consid-
ered an entry-level product, you’re free to use the full power of Microsoft’s
flagship development platform, Visual Studio. This product is fully inte-
grated with all the SQL Server 2005 database offerings, including Express.
Figure 1-1 shows you what this looks like, in the context of building a C#
class file.
⻬ Full-text searching: This feature helps you index and then query large
blocks of text-based information. Although it’s not present in SQL Server
2005 Express, you will find it in SQL Server 2005 Express with Advanced
Services. Regardless of which version you use, your application can still
store and work with this kind of information; the method you use might
vary, however.

Figure 1-1:
SQL Server
2005
Express
information
available
from inside
Visual
Studio.
14 Part I: Welcome to SQL Server 2005 Express

⻬ High availability features: The entire SQL Server 2005 product family
offers numerous technologies to help keep your database up and run-
ning at all times. However, Express doesn’t offer these capabilities, all of
which reduce down time or help improve performance:
• Online restore
• Database mirroring
• Partitioning
• Failover clustering
• Online indexing
If you’re building a mission critical application and continual uptime is
of vital importance to you, you may want to deploy your solution on one
of the other SQL Server 2005 editions.
⻬ Rich programming language choices: The entire SQL Server 2005 prod-
uct line supports the Microsoft Common Language Runtime (CLR). This
means that you can develop internal database logic such as stored pro-
cedures and triggers in any one of a number of popular programming
languages, rather than in SQL Server’s internal programming language:
Transact-SQL.
⻬ Analysis services: The more advanced editions of SQL Server 2005 fea-
ture business analytic logic that you can use to help make sense of your
information. This is especially true if your environment sports massive
volumes of data that need to be crunched to come up with recognizable
patterns. The bad news is that this is not present in SQL Server 2005
Express. However, the good news is that chances are that if these kinds
of data are found in your organization, you’ll have already purchased
one of the many third-party business intelligence products.
⻬ Report server: Users always want more information out of their data-
base. With SQL Server 2005’s reporting services, you can set up a wide
range of developer-driven and user-driven reports. You can then inte-
grate and deliver these communiqués through a series of different pre-
sentation technologies. Happily, you’ll find these capabilities present in
SQL Server 2005 Express with Advanced Services, which should help
please those finicky users. If you’re curious about how these features
work, take a look at Chapter 18 for the details.
⻬ Integration services: These features allow you to write powerful integra-
tion logic that can take information from a broad range of other data
storage locations and then store it inside SQL Server. The same holds
true for outbound data. Unfortunately, you won’t find these services pre-
sent in SQL Server 2005 Express. Luckily, this doesn’t mean that you
can’t integrate data among disparate systems; it just means that you
may have to do some more work to achieve the same results.
⻬ Notification services: This refers to the capability, found only in the
more feature-rich editions of SQL Server 2005, to build sophisticated
publish-and-subscribe applications. Once created, these applications
Chapter 1: SQL Server 2005 Express Overview 15
can properly react to a wide variety of events, notifying all interested
parties that an event has occurred. SQL Server 2005 Express does let
you take advantage of replication, but only as a subscriber.
⻬ Backup/recovery options: Because backup and recovery are a vital part
of any data integrity and reliability plan, SQL Server 2005 offers adminis-
trators a choice among several different recovery models, each of which
has its own strengths and weaknesses. However, your data-archiving
choices are somewhat more reduced for SQL Server 2005 Express. You
can still set up a very robust backup and recovery strategy; it’s just not
as full featured as in the more advanced editions of SQL Server. In partic-
ular, because the SQL Server Agent is not present, you won’t be able to
schedule jobs or configure alerts and operators.

Where Does SQL Server Express 2005


Work Best?
SQL Server 2005 Express brings a lot to the table, but when does it make
sense to choose it as your data storage platform? I answer this question in
this section.

Small office/Home office (SOHO)


Small offices and home offices (SOHO) are often caught between a rock and a
hard place when dealing with software and solutions. Either the technology is
underpowered and simplistic, not quite meeting their needs, or it’s expen-
sive, overly complex, and resource intensive.

SQL Server 2005 Express strikes a nice balance between simplicity and
power, while holding the cost as low as you can possibly get. Plus, because
many small businesses one day find themselves morphed (or acquired) into
larger enterprises, making this database server the cornerstone of your data
storage architecture means that you never outgrow your database: You can
easily upgrade to SQL Server 2005 Enterprise.

On top of that, the fact that SQL Server 2005 Express is a true relational data-
base management platform means that you can store and track just about
anything in your database. Some particularly good applications include

⻬ Inventory details
⻬ Sales statistics
⻬ Financial metrics
16 Part I: Welcome to SQL Server 2005 Express

When you have this information safely ensconced in your SQL Server 2005
Express database, you’re free to use all sorts of tools and technologies to
help make sense of your data. For example, you might store details about all
the individual transactions that your organization performs, and then use
business intelligence or other data analysis tools to help identify trends from
your sales results.

While you’re free to store anything you like in your SQL Server 2005 Express
database, be aware that any individual database has a maximum storage limit
of 4GB for your information. If you find yourself approaching that ceiling, you
need to archive some of your older data to make room for newer knowledge.

Distributed enterprise
With the rise of low cost, high-speed Internet connections, many more organi-
zations are realizing benefits from distributed computing. For the distributed
enterprise of any size, SQL Server 2005 Express offers a good balance
between the low maintenance requirements of an entry-level database like
Microsoft Access, and the capabilities of a robust, server-based database.

In addition to these features, you can administer multiple remote SQL Server
2005 Express sites from one location via the SQL Server Management Studio
Express.

Another useful capability of SQL Server 2005 Express is its ability to partici-
pate as a client in a replication architecture. This means that you could have
a single, high-end edition of SQL Server distributing its data among numerous
SQL Server 2005 Express clients. These clients could, in turn, support read-
only applications like reporting or business intelligence. This type of archi-
tecture spreads the processing load across multiple machines, and helps
eliminate bottlenecks.

Finally, another good illustration of distributed computing is to use SQL


Server 2005 Express as a local database and then aggregate its information to
a central server for safekeeping and analysis. For example, suppose that
you’re building a retail application that will support dozens of locations, none
of which will have a database administrator. You could install a traditional,
low-end database in each store, but you need to take advantage of a true rela-
tional database management system’s features, such as advanced security,
stored procedures, or triggers. You also need to gather and consolidate this
data for reporting purposes. This is a good use for SQL Server 2005 Express:
It offers enough power for enterprise-class applications without demanding
teams of highly trained administrators for its daily care and feeding.
Chapter 1: SQL Server 2005 Express Overview 17
If you’re curious about all that you can do in a distributed computing envi-
ronment, check out Chapter 6.

Independent Systems Vendor/Original


Equipment Manufacturer (ISV/OEM)
ISVs and OEMs have first-hand experience that the cost of embedded tech-
nology can eat into profits. That’s not a problem with SQL Server 2005
Express: Free generally doesn’t have much of an impact on margins. However,
don’t be fooled by the price: This is a full-featured database, built on the SQL
Server platform.

If you base your applications and solutions around SQL Server 2005 Express,
you’re not locked in: If your customers need extra horsepower and capabili-
ties, they can quickly and painlessly upgrade to a more powerful edition of
SQL Server.

The beauty of basing your solutions on a single relational database management


product family is that you can do your development on the more advanced edi-
tions of SQL Server, using robust tools like Visual Studio, and then easily deploy
your application onto the lightweight SQL Server 2005 Express.

As an added benefit to OEMs and ISVs, SQL Server 2005 Express lets you
store your data in a single, easily transferred file. Known as an .mdf file, this
structure combines the simplicity of a low-end flat file with the power of a
true relational database management system. You should note, however, that
you have to deploy the SQL Server Express 2005 server, even if you only
intend to deploy .mdf files with your solution.

Getting Down to Business with


SQL Server 2005 Express
In previous sections, I show you all that you get with your free download of
SQL Server 2005 Express Edition. If you’re wondering how you can get started
using the product, that’s what this section is all about. To begin, I point out
some things to ponder as you plan and deploy your database. Next, I talk
about all the programming tools at your disposal for building a SQL Server
2005 Express-based application. Finally, I show how you can configure and
monitor your database.
18 Part I: Welcome to SQL Server 2005 Express

What happened to MSDE?


For those of you who have followed the entry- depending on who answers the phone in
level SQL Server database for some time, you’re Redmond), this database was more compli-
probably wondering what happened to the pre- cated to administer, less feature rich, and had
vious offering from Microsoft. smaller capacity than its replacement, SQL
Server 2005 Express.
Known as MSDE (which stands for Microsoft
Desktop Engine or Microsoft Data Engine,

Planning your database


The first thing to keep in mind as you contemplate what to keep in your SQL
Server 2005 Express database is that this is not a stripped-down, feature-
limited, stand-alone product. It’s true that Express does have significant limi-
tations to the amount of information you can store in the database (see “The
SQL Server 2005 Express Environment” earlier in this chapter for more details
about that), and that certain key high-volume features are not present.

Before you get heavily into using this edition, you should make sure that
none of these limitations are showstoppers for you. Remember that the
majority of these constraints shouldn’t impact you during development;
they’re only an issue at runtime.

Even though this edition has feature restrictions, SQL Server 2005 Express
works with all the same types of information as its more fully featured sib-
lings, and you can easily migrate to a more powerful edition. It also supports
all the same application programming interfaces (APIs), as well as the same
stored procedure and trigger capabilities.

This means that as a designer, you can build your SQL Server 2005 Express
database with confidence, knowing that you aren’t painted into a corner by
missing capabilities, nor the solution you design is forever consigned to this
entry-level database. This works the other way as well: You can design your
solution on a more powerful edition of SQL Server 2005, and then deploy it
onto SQL Server 2005 Express, as long as it doesn’t require any of the fea-
tures that are only found in the more expensive editions of the product.

One feature that’s particularly attractive for distributed application develop-


ers and vendors is the Xcopy deployment capability of SQL Server 2005
Express. This lets you easily bundle your application and database (.mdf)
file and then copy them to another machine. Because everything is already
pre-packaged, you don’t need to manually configure these other platforms, as
long as they have a running instance of SQL Server 2005 Express. When your
Chapter 1: SQL Server 2005 Express Overview 19
application launches, the database server automatically attaches the .mdf
file to the local instance. This architecture results in an easily implemented
portability strategy.

Building SQL Server 2005


Express applications
You have a wide variety of electives when building a solution that stores its
information in this database. To begin, as I described earlier in this chapter,
Microsoft is making the Visual Studio Express products affordable and easy
to use to create database-driven applications. If you’re new to application
development, checking out these products is definitely worth your while. In
fact, take a look at Chapters 19 and 20, which cover Visual Basic 2005 Express
and Visual Web Developer 2005 Express, respectively. For a sneak preview,
Figure 1-2 shows how closely Visual Basic 2005 Express works with SQL
Server 2005 Express.

This tight integration can go a long way toward boosting your productivity. In
effect, with these products, Microsoft has broken down the traditional barrier
between application and database tools.

Figure 1-2:
Visual
Basic 2005
Express
and SQL
Server 2005
Express.
20 Part I: Welcome to SQL Server 2005 Express

If you’re more inclined to use heavier-weight, more powerful tools, Visual


Studio 2005 makes a lot of sense to employ for application development. It’s
an extremely potent tool that contains a tremendous amount of functionality.
It’s also very well integrated with all SQL Server 2005 products, not only the
Express edition. Naturally, all this power comes with additional complexity
and a somewhat steeper learning curve, so you should decide if your applica-
tion requires all these capabilities.

Of course, Microsoft isn’t the only game in town when it comes to application
development technologies. You can use several third-party tools (including
open source and shareware) to construct a SQL Server-based solution.

Configuring, managing, and monitoring


SQL Server 2005 Express
With your database and application built, it’s natural to turn your attention to
setting configuration parameters and then monitoring the database. Here
again, you have no shortage of options.

To begin, SQL Server 2005 Express snaps into the standard Microsoft
Computer Management console. This lets you configure and run your data-
base services, which you can see in Figure 1-3.

Figure 1-3:
Configuring
SQL Server
2005
Express
services.
Chapter 1: SQL Server 2005 Express Overview 21
For further configuring and managing your SQL Server 2005 Express server,
you can choose between graphical and character-based tools. As you might
expect, graphical tools provide more intuitive, easy-to-understand informa-
tion about your server.

When it comes to graphical tools, it’s hard to beat Microsoft’s free, excellent
graphical management environment known as SQL Server Management
Studio Express. Figure 1-4 shows a sample of what this product looks like.

SQL Server Management Studio Express can do much more than simply show
you tables and run queries. One handy tool is the activity monitor, which
opens a window onto all database-related activity for your server. Figure 1-5
shows a sample session; you can monitor a tremendous amount of informa-
tion using this tool.

For those of you who prefer a character-based configuration and manage-


ment utility, Microsoft continues to ship the SQLCMD utility, which allows for
direct entry of SQL statements. Because you find much of the administrative
capabilities for SQL Server embedded in stored procedures, you can run just
about any management operation from the rather bland SQLCMD interface.

Figure 1-4:
Viewing a
table in SQL
Server
Manage-
ment Studio
Express.
22 Part I: Welcome to SQL Server 2005 Express

Figure 1-5:
The SQL
Server
Manage-
ment Studio
Express
Activity
Monitor.
Chapter 2

Downloading and Installing


SQL Server 2005 Express
on Your Computer
In This Chapter
䊳 Getting your own copy of SQL Server 2005 Express
䊳 Laying the groundwork for installation
䊳 Installing SQL Server 2005 Express on your computer
䊳 Performing basic tests

T raditionally, getting a production-ready copy of a powerful relational data-


base management system has meant pulling out your (or the company’s)
checkbook and signing on the dotted line. However, this is not the case with
SQL Server 2005 Express. Instead, all you need is an Internet connection; you
can download the product and get started for free.

In this chapter, you find out what you need to do to get ready for SQL Server
2005 Express, along with how to download, install, and run some basic tests to
make sure everything went smoothly. After a successful installation, you still
have a few things to do before you can use the product to its fullest potential;
I show you those things in Chapter 3. If you have information stored in other
locations that you want to entrust to this database, take a look at Appendix B,
which describes how to import data into SQL Server 2005 Express.

Getting a Copy of SQL


Server 2005 Express
Microsoft has made it easy to get your own copy of SQL Server 2005 Express.
Here are just a couple ways that you can get your hands on the product:
24 Part I: Welcome to SQL Server 2005 Express

⻬ Via the Internet: If you have a fast Internet connection, you can quickly
and easily download SQL Server 2005 Express. Here’s all you need to do:
1. Point your browser to http://www.microsoft.com/sql.
2. Click the Downloads link.
You should now see a link for SQL Server 2005 Express.
3. Review the System Requirements and Instructions before down-
loading your product.
I describe some of these system requirements in the next section.
You’ll be presented with a potentially bewildering array of SQL Server
2005 Express downloads on Microsoft’s Web site. Here’s a brief overview
of each of the available products:
• Baseline SQL Server 2005 Express: This is the standalone, entry-
level SQL Server database found in SQLEXPR.EXE.
• SQL Server 2005 Express with Advanced Services: This is the
next level up in database power and capability, yet it’s still free! If
you’re interested in enhanced reporting services and full-text
searching, this might be the edition for you (see Chapter 18). It’s in
a file entitled SQLEXPR_ADV.EXE.
• SQL Server Management Studio Express: This is an excellent,
powerful, yet easy-to-use database administration and interaction
tool. I strongly recommend getting a copy; you won’t regret it.
• SQL Express toolkit: If you’re interested in developing reports with
SQL Server 2005 Express with Advanced Services, the Business
Intelligence Development Studio contained in this toolkit is a
must-have.
If you can’t get to SQL Server 2005 Express via the preceding instruc-
tions, just use the Search feature on the Microsoft Web site to find it
quickly.
⻬ Via Visual Studio 2005: SQL Server 2005 Express is part of a larger
group of low-priced Microsoft offerings, known as the Express editions.
These products are aimed at a wide audience of developers that might
not have used these types of solutions before, and include
• Visual Basic 2005 Express Edition (which is conveniently on this
book’s CD)
• Visual Web Developer 2005 Express Edition
• Visual C# 2005 Express Edition
• Visual C++ 2005 Express Edition
• Visual J# 2005 Express Edition
Microsoft also bundles SQL Server 2005 Express with Visual Studio 2005,
which is available for purchase either stand-alone or via the Microsoft
Developer Network (MSDN).
Chapter 2: Downloading and Installing SQL Server 2005 Express 25
⻬ Via the CD that ships with this book: To make things even easier for
you, a fully functional copy of SQL Server 2005 Express with Advanced
Services is on the CD that comes with this book. You can read more
about it in Appendix D.

Before You Install


Although popping in the CD or pointing your browser at the Microsoft
Web site and then downloading and installing SQL Server 2005 Express is
tempting, you need to make sure that your computer meets some minimal
requirements. Otherwise, you could be faced with a long and frustrating
troubleshooting session, trying to figure out why things are running poorly
(or even not at all!).

Take the time to go through each of these major system readiness categories,
making sure that you meet or exceed each of these prerequisites. Also, if
you’re installing SQL Server 2005 Express on multiple machines, remember
that the machine that acts as a central server generally requires faster and
better hardware than one that primarily acts as a client. Finally, you need to
have administrative privileges on the computer where you’re installing SQL
Server 2005 Express.

⻬ CPU: For optimal performance, you want at least a 600 MHZ CPU,
although things might be kind of sluggish at that speed. Using a 1GHZ
CPU definitely makes things peppier and is recommended.
⻬ Memory: Because sufficient memory serves as the foundation of any
well-performing relational database, make sure that you provide 512MB
or more, as recommended by Microsoft. You could probably get away
with 192MB (minimum), but you’re pushing things at that level. In gen-
eral, just as you can’t be too rich or too thin, you can’t provide a rela-
tional database with too much CPU or memory, although SQL Server
2005 Express will not use more than 1GB of RAM.
⻬ Disk: Given that relational databases use disk drives as their primary
storage mechanism, recommending a hard-and-fast value for the right
amount of available disk capacity is difficult: Every installation is differ-
ent. Just the product and its related files take up more than 500MB of
disk space; you’ll likely want to add one or two gigabytes on top of that
for your data.
⻬ Operating system: Microsoft gives you a fairly wide choice of operating
systems that can run SQL Server 2005 Express. They include
• Windows Server 2003
• Windows Small Business Server 2003
• Windows XP Home Edition
• Windows XP Media Center Edition
26 Part I: Welcome to SQL Server 2005 Express

• Windows XP Professional Edition


• Windows XP Tablet PC Edition
• Windows 2000 Advanced Server
• Windows 2000 Professional Edition
• Windows 2000 Server
Be prepared to apply the latest service pack for your operating system;
in many cases, SQL Server 2005 Express depends on these patches.
⻬ Supporting software: Because it’s built on top of some of Microsoft’s
newer technologies, SQL Server 2005 Express requires that you install
some additional software technologies, specifically the Microsoft .NET
Framework 2.0. You also may be required to deploy the new Microsoft
Windows Installer software. In addition to facilitating software installa-
tion, this new product also checks whether your Windows software is
licensed correctly. Both of these products are free, and available for
download from the Microsoft Web site.
⻬ If you plan to use the Advanced Services edition, and are interested in
its reporting capabilities, make sure that you have Microsoft Internet
Information Services installed on your computer.

Installing SQL Server 2005 Express


Kudos to you if you took the time to read the previous section that described
the prerequisites for installing SQL Server 2005 Express. And if you didn’t,
that’s okay, too. Now all you need to do is breeze through a few simple steps,
and you’re ready to start using your new database. Here’s how to get SQL
Server 2005 Express up and running:

1. Remove old software.


If you’ve installed any beta editions of SQL Server 2005 Express or the
SQL Native Client, you need to uninstall them via the Control Panel’s
Add and Remove Programs utility.
2. Back up your system.
It may seem a bit excessive, but you’ll never regret taking the time to
make a backup copy of your important information. If things go wrong,
you have a way of restoring your data. And if things go fine (which they
probably will), you’ve still safeguarded your computer.
3. (Optional) Defragment your disks.
This may not seem like the time to defragment your disks, but in fact it’s
a great opportunity to give SQL Server 2005 Express some nice, clean,
well-organized space with which to work. Over time, data on your disk
drives gets fragmented, and spreads across the entire disk. This can
Chapter 2: Downloading and Installing SQL Server 2005 Express 27
hurt performance of all applications; SQL Server 2005 Express is no
exception. Here’s how to defragment your disk:
a. Launch the Windows Disk Defragmenter.
You’ll find it via Start➪Programs➪Accessories➪System Tools➪
Disk Defragmenter.
b. Click the Analyze button.
The Disk Defragmenter analyzes your disk and returns a recom-
mendation (see Figure 2-1).
c. If the Disk Defragmenter recommends that you defragment your
disk, click the Defragment button.
This may take some time to complete, but be patient: It’s worth it.

Figure 2-1:
A disk that
needs to be
defrag-
mented.

4. Install the Microsoft .NET Framework.


This is the foundation on which SQL Server Express was built. You can
download it for free from the Microsoft Web site. In fact, you will find a
handy link to it right on the SQL Server 2005 Express download page.
5. Run the SQL Server 2005 Express installer program.
If you install SQL Server 2005 Express via the Visual Studio installer, you
may have a slightly different set of instructions.
After you launch the installer, you see a screen similar to Figure 2-2.
Once these initial tasks are out of the way, the SQL Server 2005 Express
Installation Wizard launches, which is shown in Figure 2-3.
28 Part I: Welcome to SQL Server 2005 Express

Figure 2-2:
The initial
SQL Server
2005
Express
installation
prerequisite
screen.

SQL Server 2005 Express runs some very sophisticated checks against
your system to make sure that the upcoming installation goes smoothly.
Each configuration check is flagged as Success, Error, or Warning.
You must correct errors; you can get away with ignoring warnings, but
things may not run very smoothly if you do so.

Figure 2-3:
The SQL
Server 2005
Express
Installation
Wizard.
Another Random Scribd Document
with Unrelated Content
back
back
back
back
back
back
back
back
back
back
back
back
back
back
back
back
back
back
back
Welcome to Our Bookstore - The Ultimate Destination for Book Lovers
Are you passionate about books and eager to explore new worlds of
knowledge? At our website, we offer a vast collection of books that
cater to every interest and age group. From classic literature to
specialized publications, self-help books, and children’s stories, we
have it all! Each book is a gateway to new adventures, helping you
expand your knowledge and nourish your soul
Experience Convenient and Enjoyable Book Shopping Our website is more
than just an online bookstore—it’s a bridge connecting readers to the
timeless values of culture and wisdom. With a sleek and user-friendly
interface and a smart search system, you can find your favorite books
quickly and easily. Enjoy special promotions, fast home delivery, and
a seamless shopping experience that saves you time and enhances your
love for reading.
Let us accompany you on the journey of exploring knowledge and
personal growth!

ebookgate.com

You might also like