We'll make much use of the pubs and Northwind databases for our examples in this book. Here's a tip for restoring them to their default condition. First, login as SA in Query Analyzer. Then, go to your SQL Server installation directory and browse to the INSTALL subdirectory under it. From this directory, run either the INSTPUBS.SQL or INSTNWND.SQL script in Query Analyzer to refresh the pubs or Northwind database, respectively. If your server is only in integrated mode, run the scripts, and then run the following script in the Query Analyzer:
USE dbname GO EXEC sp_changedbowner 'domain\userID' GO EXEC sp_changedbowner sa GO
Here, dbname is either pubs or Northwind, and domain\userID will be your domain name and the user ID that you are logged in as while running the scripts. Note, that the quotes are necessary because of the backslash (\) in the string. This script will restore your pubs or Northwind database to the default condition. Note it will also put the guest account back into both databases – we'll talk more about the security issues raised by this account in Chapter 8.