Installing the Example Databases


The process of installing the example databases is a bit more complicated. Before getting started, you're going to want to choose a SQL Server instance to host one or all of the example databasesthere are six of them in the Databases folder on the DVD, as shown in Figure I.2.

Figure I.2. The "Databases" directory on the companion DVD.


No, you won't be able to attach the database files to SQL Server while they're on the DVDyou'll have to copy them to the system that's hosting your target SQL Server instance. Check with your DBA or whomever is managing your SQL Server instancesor look in the mirror and ask yourself if you have room for these databases on an existing instance. Perhaps, you should install a separate SQL Server instance to use as a test database. SQL Server Express is included with all versions of Visual Studioany or all of the databases and examples can be executed against a stand-alone SQL Server instance. I don't recommend using Visual Studio Express and simply adding any of these databases to your projects.

No matter which version of SQL Server you choose to use, you'll still have to configure it to support CLR procedures (if this makes sense to your DBA) and network visibility, as discussed in the book. I don't suggest that you install these sample databases on a production server or one that can't tolerate the extra load.

Tip

Don't install these sample databases on a production server or one that can't tolerate the extra load.


Attaching the Example Databases

Once the .MDF and .LDF files for each database you wish to install are copied to a (nonremovable) drive on the host system, you're ready to attach the databases. Let's take a quick look at the databases included on the DVD and listed in Figure I.2.

  • The Data directory This holds a set of flat files and other sample (non-SQL Server) databases.

  • BCPTest Used as a target by the SqlBulkCopy example.

  • BookSource Used in a number of the SQL Server CLR executable stored procedure and function examples.

  • Common Used to hold "common" SQL Server CLR executable functions.

  • Currency Used in a number of the SQL Server CLR executable user-defined type (typICurrency) examples.

  • GPS Used in the SQL Server CLR executables that access city/town lists stored with their GPS locations.

  • NewBiblio_Data (Biblio) This is the primary example database. It's used by the bulk of the examples in the book.

I suggest installing just the NewBiblio_Data.MDF (Biblio) database until you're ready to work with the more advanced portions of the book. While I've included a SQL script to attach all of these databases on the DVD, I suggest you use SQL Server Management Studio (or the Express edition) to attach the selected databases. While I discussed how to do this in Chapter 2, "How Does SQL Server Work?", remember that you simply right-click on "Databases" in the Object Explorer and choose "Attach". The dialog prompts you for an .MDF file location. SQL Server Management Studio automatically searches for the .LDF file and attaches both to SQL Server when you click "OK."

Establishing an Alias to Your Instance

All of the example applications reference the target SQL Server via an Alias of "DemoServer". This permits you to point to any named instance of SQL Server in the ConnectionString by using another namethus, "Alias". Creating an alias is very simplejust follow along:

1.

Start Microsoft SQL Server 2005 | Configuration Tools | SQL Server Configuration Manager. This MMC console application was discussed in detail in Chapter 2. It's used to manage the installed instances of SQL Server 2005, as well as establish aliases to any SQL Server instance.

2.

Click the "+" sign next to "SQL Server Native Client Configuration," as shown in Figure I.3 to expose the Aliases tree. Right-click on "Aliases" to expose the operations menu and choose "New Alias..." to create a new Alias.

Figure I.3. Opening the Aliases tree in SQL Server Configuration Manager.


3.

This opens the dialog shown in Figure I.4, which prompts you for the Alias Name. In this case, set this to "DemoServer"; the Port No, which I left blank to use an automatically generated port number; the Protocol, which defaults to "TCP/IP" (which you can set as requiredjust make sure the SQL Server has the selected protocol enabled); and finally the Server entry. The Server entry requires that you name the server as you would in the ConnectionString. This can refer to a "local" instance of SQL Server or a remote server hosted on another system on your network. See Chapter 9, "Getting Connected," for details on creating a valid SQL Server instance address. When you click "OK" in this dialog, the Alias is registered with the local system, so any references to the alias are translated to access the "Sever" entry.



Figure I.4. Configuring a new Alias.





Hitchhiker's Guide to Visual Studio and SQL Server(c) Best Practice Architectures and Examples
Hitchhikers Guide to Visual Studio and SQL Server: Best Practice Architectures and Examples, 7th Edition (Microsoft Windows Server System Series)
ISBN: 0321243625
EAN: 2147483647
Year: 2006
Pages: 227

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net