Create a Database in SQL Server 2017

Here's how create a database in SQL Server using SQL Operations Studio (now called Azure Data Studio).

Creating a database in SQL Server is as easy as running a script. Some GUI database management tools enable you to create a database via the GUI (i.e. by "pointing and clicking") instead of running a script, but usually those GUI tools also provide the means to do it via a script.

In this tutorial, we'll create a database by running a script.

Connect to SQL Server

Regardless of which database management tool you use, you still need to connect to SQL Server. We'll do that first.

  1. Launch your Database Management Tool

    Launch your database management tool if you haven't done so already.

    In this tutorial we use SQL Operations Studio (now called Azure Data Studio). You can launch Azure Data Studio the same way you'd launch any other application in your operating system. For example, in macOS click its icon in your Applications folder.

  2. Connect to SQL Server

    Enter the SQL Server connection details.

    Here are the details I used on the SQL Server installation tutorial:

    • Server Name: localhost
    • Authentication Type: SQL Login
    • User name: sa
    • Password: myPassw0rd
    • Database Name: <default>
    • Server Group: <default>

    If you're connecting to a different machine, replace localhost with the name of that machine. Also replace the User name and Password with your own login details if they're different.

    Most GUI tools use a similar process to connect. However, some tools might require you to go through a connection wizard and/or install a driver (like my connection with DBeaver). If you use a command line tool, you'll need to enter the connection details as a command (here's an example using sql-cli).

    Screenshot of connecting to SQL Server with SQL Operations Studio (SQLOPS)

Create the Database

Now that we've connected to SQL Server, we can go ahead and create the database.

  1. Open a New Query Tab

    Click the New Query button to open a new query tab (unless one is already open).

    Screenshot of SQLOPS with the New Query button highlighted
  2. Run the Script

    Enter the following line and click Run:

    That command creates a database called Music.

    Screenshot of SQLOPS with the Run button highlighted
  3. View the Database

    Your new database should now appear under the Databases node in the left panel. If not, you might need to refresh the list before the database appears.

    To refresh, right-click on Databases and select Refresh to refresh the list of databases.

    Screenshot of SQLOPS with the Refresh option highlighted

A More Complete Database

That database we just created is an empty database. It has no tables, and it contains no data. That's not much fun.

Throughout the rest of this tutorial, we'll add some tables and data. We'll also run queries against the data.