• Express Edition. This free, feature-limited version is available for download. It
• Express Edition. This free, feature-limited version is available for download. It
supports one CPU, 1 GByte of memory, and a maximum database size of 10 GBytes. Despite its limitations, it is a great learning tool when the Express Advanced version, which includes the SQL Server 2008 R2 Management Studio and a basic reporting services package, is used (and did we mention that it’s free?).
As mentioned earlier, Microsoft is poised to release the next version of SQL Server—SQL Server 2011. Although we cannot show screenshots of the
prerelease version of SQL Server 2011 we have been using, we have tested all the SQL Server commands and SQL statements in this book in SQL Server 2011, and they all run correctly in the prerelease version of SQL Server 2011. So while we will undoubtedly see some changes, the core functionality should be maintained, and the SQL Server 2011 Management Studio should retain most of functionality of the SQL Server 2008 R2 Management Studio discussed in this book.
The SQL Server Express Edition was introduced with SQL Server 2005, and SQL Server 2008 R2 includes the SQL Server 2008 R2 Express version. The SQL Server Express editions seem to be designed to compete with Oracle’s MySQL Community Server (see Chapter 10B). MySQL, although not having as many features as SQL Server, is an open- source database that has had the advantage of being available for free via download over the Internet. It has become widely used and very popular as a DBMS supporting Web sites running the Apache Web server.
Chapter 10 Managing Databases with SQL Server 2008 R2
SQL Server 2008 R2 Express Advanced is the version of SQL Server 2008 R2 Express that contains an advanced features package. The advanced features package includes Microsoft’s GUI SQL Server management tool and support for SQL Server Reporting Services. Both of these features are well worth having, so download and install the version with the advanced features package.
For SQL Server 2008 R2 Express, you can start at the SQL Server 2008 R2 homepage at www.microsoft.com/sqlserver/en/us/default.aspx , and then click the Express Edition button to go to the SQL Server 2008 R2 Express Installation Options page (www.microsoft.com/ express/Database/InstallOptions.aspx ). From this Web page, download and install either the 32-bit or 64-bit version of the Database with Advanced Services option (depending on whether your Windows OS is a 32-bit or 64-bit version, although the 32-bit version will run on a 64-bit OS).
The SQL Server 2008 R2 Express Edition with Advanced Services installation should install any prerequisite programs, including the needed version of the Microsoft .NET framework. If there are non-included prerequisite programs that you must install, you will be prompted to download and install them.
Note that Microsoft SQL Server 2008 R2 Management Studio is included in the download of Microsoft SQL Server 2008 R2 Express Advanced. If you choose to download the basic version of SQL Server 2008 R2 Express, you must download and install this program separately. Microsoft SQL Server 2008 R2 Management Studio is the graphical management utility for the SQL Server 2008 R2 Express edition. Although SQL Server 2008 R2 was originally
a command-line-oriented program, SQL Server 2008 R2 Management Studio makes it much easier to work with SQL Server.
SQL Server 2008 R2 Express is one of several Express Editions available from Microsoft. For more information on the Microsoft Express series of
products, a good place to start is www.microsoft.com/express. Although SQL Server 2008 R2 Express Advanced can handle most of the topics in this book, it cannot handle advanced business intelligence (BI) systems topics, which are discussed in Chapter 13. For that you will need the Enterprise Edition. A 180-day trial version can be downloaded from Microsoft (www.microsoft.com/sqlserver/en/us/get-sql-
server/try-it.aspx).
You may also want to download and install the following software from the SQL Server 2008 R2 Feature Pack, depending on whether SQL Server 2008 R2 is installed on your workstation or on a separate server. Start at the Microsoft SQL Server 2008 Download Trial Software Web page at www.microsoft.com/sqlserver/2008/en/us/trial-software.aspx, and then in the Download the SQL Server 2008 R2 Feature Pack section, click the Download it now button to ensure that you are taken to the most current set of software. Be sure to scroll completely through the Web page to see the complete set of available software packages:
• Microsoft Core XML Services (MSXML) 6.0 • Microsoft SQL Server 2008 Command Line Utilities • Microsoft SQL Server 2008 Native Client • Microsoft SQL Server 2008 Data Mining Add-ins for Microsoft Office 2007 (also
works with Office 2010) Be aware that SQL Server 2008 R2 is an enterprise-class DBMS and, as such, is much more
complex than Microsoft Access. Further, it does not include application development tools, such as form and report generators.
Regardless of which version of SQL Server 2008 R2 you are going to use, you should install it now. You should then check for the latest service packs and patches to make sure your installation is as secure as possible.
Part 4 Multiuser Database Processing
The Microsoft SQL Server 2008 R2 Management Studio
After you install SQL Server 2008 R2, you can start working with SQL Server by opening the Microsoft SQL Server 2008 R2 Management Studio. In this book, we are running SQL Server 2008 R2 Enterprise Edition in Microsoft Server 2008 R2. To open the Microsoft SQL Server Management Studio in Windows Server 2008 R2 or in the Windows 7 operating system, select Start | All Programs | Microsoft SQL Server 2008 R2 | SQL Server Management Studio
Express. 1 The Microsoft SQL Server Management Studio Connect to Server dialog box appears, as shown in Figure 10-1, and clicking the Connect button connects you to the DBMS using your Windows OS authentication.
After you have done this, find the folder icon labeled Databases in the Object Explorer, as shown in Figure 10-2. Click the plus sign to open it, and then open the System Database folder the same way. As shown in Figure 10-2, objects representing the databases managed by the SQL Server 2008 R2 DBMS are displayed in these folders. For example, you can see the Cape Codd database that we used in our discussion of SQL queries in Chapter 2. We normally keep the System Databases folder closed because we usually do not work with these databases.
Creating an SQL Server 2008 R2 Database
Now that the SQL Server 2008 R2 is installed and the Microsoft SQL Server Management Studio is open, we can create a new database. We will create a database named VRG for the View Ridge Gallery database we designed in Chapter 6, and for which we wrote the SQL statements in Chapter 7.
Creating an SQL Server 2008 R2 Database
1. Right-click the Databases folder in the Object Explorer to display a shortcut menu, as
shown in Figure 10-3.
2. Click the New Database command to display the New Database dialog box, as
shown in Figure 10-4.
3. Type the database name VRG in the Database Name text box, and then click the OK button. The database is created and the VRG database object is displayed in the
Using Windows
Authentication
will supply the current user name and password
Click the Connect button
Figure 10-1
The Connect to Server Dialog Box
1 If you are using the Windows XP or the Windows Vista operating system, select Start | All Programs | Microsoft SQL Server 2008 | SQL Server Management Studio.
Chapter 10 Managing Databases with SQL Server 2008 R2
The Object Explorer shows SQL Server 2008 R2 objects and the folders that are used to contain and organize those objects
The Databases folder contains database objects for the databases that we create
The Cape-Codd Database object The System
Databases folder The ReportServer and contains database
ReportServerTempDB database objects for the
objects hold databases used by databases
SQL Server 2008 R2 Reporting automatically created
Services
by SQL Server 2008
Figure 10-2
Object Explorer, as shown in Figure 10-5. Click the plus (+) button to display the VRG
The Microsoft SQL Server
folders, also shown in Figure 10-5.
Management Studio Window
4. Right-click the VRG database object to display a shortcut menu, and then click the Properties command. The Database Properties – VRG dialog box is displayed, as shown in Figure 10-5.
5. In the Database Properties – VRG dialog box, click the Files page object, as shown in Figure 10-5. The database files associated with the VRG database are displayed.
6. Click the OK button in the Database Properties – VRG dialog box to close the
dialog box. If you look at the database files listed for the VRG database in the New Database dialog box in
Figure 10-4, and displayed again on the Files page of the Database Properties – VRG dialog box,
Right-click Databases to display the shortcut menu
The Databases
shortcut menu
Click New Database to create a new database
Figure 10-3
The New Database Command
Part 4 Multiuser Database Processing
The New Database dialog box
Type the new database name here
Click the OK button to create the new database
Figure 10-4
Naming the New Database
as shown in Figure 10-5, you will see that by default SQL Server creates one data file (logical name VRG) and one log file (logical name VRG_log) for each database. You can create multiple files for both data and logs and assign particular tables and logs to particular files and file groups. However, all of this is beyond the scope of our current discussion. To learn more about it on your own, use the SQL Server 2008 R2 help system.
SQL Server 2008 R2 Utilities
Now that we have created the VRG database itself, we need to create the table and relationship structure of the database, and then populate the tables with data. What SQL Server 2008 R2 utilities or tools shall we use to do this? It turns out that we have several choices.
The Database
Properties – VRG
dialog box with the Files page selected
The VRG database object in the Object Explorer expanded to show the folder structure that will be used to contain the database objects
The OK button
Figure 10-5
The VRG Database in the Object Explorer
Chapter 10 Managing Databases with SQL Server 2008 R2
The SQL Server PowerShell command line tool running the sqlps utility that adds SQL CMD capabilities
The command prompt—the command is entered after the greater than (>) symbol
Figure 10-6
The SQL Server PowerShell Command Line Utility in the Microsoft SQL Server Management Studio