Home > Articles > Data > SQL Server

Creating a SQL Server Database

  • Print
  • + Share This
This lesson from T-SQL in One Hour a Day, Sams Teach Yourself covers how to create a SQL Server database, how to set database options, how to work with the Transaction Log, and how to attach to an existing database.
This chapter is from the book

Databases are at the heart of every SQL Server system. They contain the tables, database diagrams, views, stored procedures, functions, and triggers that comprise the system. This lesson covers:

  • How to create a SQL Server database
  • How to set database options
  • How to work with the Transaction Log
  • How to attach to an existing database

Creating the Database

Before you can build tables, views, stored procedures, triggers, functions, and other objects, you must create the database in which they will reside. A database is a collection of objects that relate to one another. An example would be all the tables and other objects necessary to build a sales order system. To create a SQL Server database, follow these steps:

  1. Right-click the Databases node and select New Database. The New Database dialog box appears (see Figure 3.1).

    FIGURE 3.1

    FIGURE 3.1 The New Database dialog box enables you to create a new database.

  2. Enter a name for the database.
  3. Scroll to the right to view the path for the database.
  4. Click the Ellipsis button. The Locate Folder dialog box appears.
  5. Select a path for the database (see Figure 3.2).

    FIGURE 3.2

    FIGURE 3.2 You can opt to accept the default path, or you can designate a path for the database.

  6. Click OK to close the Locate Folder dialog box.
  7. Click to select the Options page and change any options as desired (see Figure 3.3).

    FIGURE 3.3

    FIGURE 3.3 The Options page of the New Database dialog box enables you to set custom options for the database.

  8. Click OK to close the New Database dialog box and save the new database. The database now appears under the list of databases (see Figure 3.4) under the Databases node of SQL Server Management Studio. If the database does not appear, right-click the Databases node and select Refresh.

    FIGURE 3.4

    FIGURE 3.4 The new database appears under the list of databases in the Databases node.

  • + Share This
  • 🔖 Save To Your Account