MS SQL Server Access

Info

With the new policies regarding the K-State VPN, I am working on an alternative for those of you who cannot install MS SQL Server on your own machine. I will post updates as soon as possible!

In order to complete homework assignments and practice on your own, you will need access to SQL Server. Your access requires a client tool and a server.

Client Tools

For this course, you will need to use a SQL client tool to access a SQL Server instance. Here are a few client tools that are available for use; however, we will be focusing our use on VS Code this semester:

Database Server

A database server is needed to host a database in addition to client tools which are used to access the database and run queries. In this course, we will use Microsoft SQL Server.

Option 1: Docker/Github Codespace

If you are unable to install SQL Server on your own machine, you can use a GitHub Codespace or Docker that has SQL Server already installed. This is provided via a GitHub classroom link in Canvas, along with instructions.

Option 2: Install Your Own

Installing your own copy of Microsoft SQL Server is highly encouraged. Most versions of SQL Server will work for this course…but I recommend the one below for a lightweight option (the full version of MS SQL Server is not needed for this course and can take up quite a bit of resources when installed).

  • MS SQL Server Express: A light-weight server that is often used for local development. It is an installation option of SQL Server Express Edition.

    1. You can install SQL Server Express here: SQL Server Express. The “Basic” installation option is sufficient.

      1. Alternatively, you can install LocalDB. For more information, see https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/sql-server-express-localdb. This runs with even a smaller footprint than Express. If you go with this option, you will use a different server name to connect below in step 2: (localdb)\MSSQLLocalDb
    2. Now you can run one of the above client tools to connect to your local instance of SQL Server. You need to use the following information to connect in a query window:

      • Server Type: Database Engine
      • Server Name: localhost\SQLEXPRESS
      • Authentication Type: Windows Authentication
    3. Install the WideWorldImporters database. It it is hosted on github.com. For for our use, you can download the WideWorldImporters-Standard.bak copy of the database. Once the backup file is downloaded, move it to your user directory and issue the following SQL to restore the backup:

    RESTORE DATABASE [WideWorldImporters]
    FROM DISK = N'THEPATH\WideWorldImporters-Standard.bak'
    WITH FILE = 1,
    MOVE N'WWI_Primary' TO N'THEPATH\WideWorldImporters.mdf',
    MOVE N'WWI_UserData' TO N'THEPATH\WideWorldImporters_UserData.ndf',
    MOVE N'WWI_Log' TO N'THEPATH\WideWorldImporters.ldf';
Info

Note that since SQL Server Express typically runs under its own user in Windows, you may run into some file permission issues (Access Denied errors) when trying to run the above commands. If this is the case, move the .bak file to the Data folder inside your SQL Server install location. In most cases, this would be where that folder is located (version might be different): C:\Program Files\Microsoft SQL Server\MSSQL15.SQLEXPRESS\MSSQL\DATA. Try running the commands above again, but now with the .bak file at this location.