Querying your Sitecore SQL container

Occasionally you may need to connect to the Sitecore SQL instance and inspect the databases when running in docker. This is relatively straightforward.

Using SQL Manager

1. Identify the IP address of your SQL Instance

PS> docker inspect container [options] <container id/name>

dockerinspect

NOTE: IP address changes every time you run docker-compose up.

If you are not sure of the name of your container name or id you can use the following command to get list of running containers
PS> docker container ls

2. Grab the SQL password for the SA account.

In the root of the solution open the .env file and grab the SQL_SA_PASSWORD setting value.

3. Fire up SQL Management Studio and connect

Set the Server name = ip address from step 1
Login = sa
Password = password from step 2
And Connect

Using MS Code

The mssql extension for Visual Studio Code is pretty awesome as it lets you connect to a SQL Server and query and view results with T-SQL.

To install the mssql extension

  1. select View > Command Palette, or press Ctrl+Shift+P, or press F1 to open the Command Palette.
  2. In the Command Palette, select Extensions: Install Extensions from the dropdown.
  3. In the Extensions pane, type mssql.
  4. Select the SQL Server (mssql) extension, and then select Install.

Connect to Sitecore SQL database Instance

  1. Click on the SQL Server icon or CTRL + Alt + D
  2. Click add connection and follow the prompts
    • enter Server name/ip – use container ip located above using container inspect
    • database name (optional) you could connect to a specific sitecore DB
    • authentication  Type: SQL Login
      • sa
      • SQL_SA_PASSWORD setting from .env file
    •  name your profile

mscode_sitecoresql

DONE!

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s