I’m in the TOP 30 SQL Server Bloggers of 2018

Top 30 SQL blog 2018Today, I accidentally discovered that I’m in the TOP 30 SQL Server Bloggers of 2018 by SQLShack. This is a big surprise and I’m very happy that I received such amazing recognition. It’s a great feeling to be on such a list with all these well-known #SQLFamily members.

I couldn’t imagine more perfect timing. Speaking quite frankly, I have a hard time to get back to blogging after my vacation break and this recognition is a huge motivation for me to resume work on my posts.

I will try to publish my blog posts regularly in September, however, it may be difficult because I’m also preparing to pass the AWS Certificate exam by the end of this year. Keep fingers crossed!


Share it:

The most useful Docker commands for DBA

In my latest blog post, I described How to start SQL Server Docker container in few simple steps. Since then I was playing a bit with Docker and now I want to share with you a list of the most useful Docker commands.

Check Docker version

You can check Docker version very easily using this command:

docker version

Example output:

Docker version

List downloaded images

To display a list of already downloaded (pulled) images use one of these commands:

docker image ls
docker images

Example output:

Docker images

Search for new image

You can use https://hub.docker.com/ to search for new images, but you can do this also from command line.

docker search [searchphrase]

Example output:

Docker search

Pull the image

To pull (download) the image you need to run this command:

docker pull <imagename>

Example output:

Docker pull

Run new container

To run new container use this command:

docker run <imagename>

Example output:

Docker run hello-world

Sometimes you need to provide additional parameters.

docker run --name <CONATINER_NAME> -d -p 1433:1433 -e sa_password=<SA_PASSWORD> -e ACCEPT_EULA=Y microsoft/mssql-server-windows-developer
Docker run mssql
List containers

To list running containers use:

docker ps

Docker ps

To list all created containers use:

docker ps -a

Docker ps -a

Stop container

To stop container:

docker stop <container ID>

To stop all running containers:

docker stop $(docker ps -a -q)
Start container

To start container:

docker start <container ID>

To start all containers

docker start $(docker ps -a -q)
Remove container

To remove container:

docker rm <conatiner ID>

To remove all containers:

docker rm $(docker ps -a -q)
Remove image

To remove image:

docker rmi <image ID>

Docker rmi

Copy files

To copy files between host and container use cp command:

docker cp <Container ID>:<Container path> <host path>
docker cp <host path> <Container ID>:<Container path>


I hope you find this list useful. Thanks for reading!


Share it:

How to start SQL Server Docker container in few simple steps

SQL Server 2017 is the first SQL Server version that is available on Windows, Linux, and in Docker containers. In this blog post, I will show you how to create your first SQL Server Docker container in a few very simple steps.

What is Docker?

Docker is an open-source container platform provider written in GO programming language. It’s available for Linux, Windows, and MacOS. In addition, it also works in Azure and AWS environments. Containers allow developers to package up an application with all of the parts it needs, such as libraries and other dependencies, and deliver it all out as one package. It’s something similar to Virtual Machines but without the guest operating system. They’re isolated, but they share Host OS. That makes them smaller and more lightweight.

container vs vm

Docker installation

Currently, for Windows users, Docker is available in two editions. Docker Community Edition for Windows (CE) is a free solution designed for Windows 10 users. Docker Enterprise Edition for Windows Server (EE) is dedicated for Windows Server 2016 users. There is also third (legacy) solution – Docker Toolbox with support for Windows 7 and 8. However, this edition has some additional requirements and limitations, for example, it supports only Linux containers.

Docker CE

To install Docker CE you need to follow two very simple steps:

  1. Download Docker CE installer from Docker Store.
  2. Double-click Docker for Windows Installer.exe and follow the install wizard to accept the license, authorize the installer, and proceed with the install.
Docker EE

Installation of Docker EE is more automated and can be performed using PowerShell:

  1. Open PowerShell command prompt and run following command to install Docker:
    Install-Module DockerProvider -Force
    Install-Package Docker -ProviderName DockerProvider -Force
  2. If prompted to install any prerequisites such as NuGet, type in “Y”.
  3. Run the following command to check if a reboot is required:
    (Install-WindowsFeature Containers).RestartNeeded
  4.  If the result is Yes, restart your computer with this command:
    Docker Toolbox

Installation of Docker Toolbox is quite similar to the installation of Docker CE.

  1. Download Docker Toolbox installer.
  2. Install Docker Toolbox by double-clicking the installer.

The installer installs following software on your machine:

  • Docker Client for Windows
  • Docker Toolbox management tool and ISO
  • Oracle VM VirtualBox
  • Git MSYS-git UNIX tools

Installation validation

When Docker is already installed and running you may want to check if it works properly. For Docker CE and EE, start PowerShell command prompt. For Docker Toolbox, open Docker Toolbox Terminal (Docker QuickStart  Terminal). Then run the following command to check your installed version:

docker --version

docker version

Next step is to check if Docker can pull and run containers:

docker run hello-world

docker run hello-world

Creating SQL Server Docker container

Currently, Microsoft provides three SQL Server Docker containers:

You may look for them on Docker Hub page or you also may run the following command to list available images:

docker search microsoft

docker search microsoft

Pull needed image

The first thing to start your container is to pull the image from the repository. Depending on what image you want to use you need to execute one of the following commands:

docker pull microsoft/mssql-server-linux
docker pull microsoft/mssql-server-windows-developer
docker pull microsoft/mssql-server-windows-express

Important: Docker Toolbox supports only Linux containers. Docker CE and EE support Linux and windows containers, however, to pull and run docker image without any issues you need to ensure that your Docker installation is running in the proper mode. You may do it by right-clicking on the Docker whale icon in your tray docker icon.

I decided to download SQL Server Developer on Windows image.

docker pull

To check what images are downloaded run the following command:

docker images

docker images

Run new container

Finally, you’re ready to run your container. To do it you need to execute docker runcommand and provide few mandatory parameters.

  • --name – provide a name for your container
  • -d – run container in detached mode (in the background)
  • -p – publish a container᾿s port or a range of ports to the host. For example -p 14333:1433 maps port 14333 on the host to port 1433 in the container.
  • -e – create environment variables under the container execution runtime
    • sa_password (to assign the SQL Server SA password)
    • ACCEPT_EULA (to accept end-user license agreement)


docker run --name <CONATINER_NAME> -d -p 1433:1433 -e sa_password=<SA_PASSWORD> -e ACCEPT_EULA=Y microsoft/mssql-server-windows-developer

docker run mssql

Here you can find more details about docker run command.

How to connect to your new SQL Server?

The last thing is to connect to new SQL Server instance. To do this open SQL Server Management Studio and as Server name provide localhost with the port you specified for mapping. Then, choose SQL Server authentication and log in using sa account (with the password you specified during container setup).

SSMS - connect

Now you can run any queries you want.

SSMS - query


Share it:

QuickQuestion: How to start and stop SQL Server instance from a command line?

QuickQuestion series is a series of short posts in which I answer database related questions asked by my colleagues, friends, and co-workers, mainly application developers.

Today’s question:

How to start and stop SQL Server instance from a command line?


SQL Server instance as any other Windows network service can be managed using the NETcommand from elevated Command Prompt (Run as Administrator).

net options

To start default SQL Server instance use following command:

net start "SQL Server (MSSQLSERVER)"



To start named SQL Server instance use following command:

net start "SQL Server ( instancename )"


net start MSSQL$ instancename

SQLServer - net start

To stop default SQL Server instance use following command:

net stop "SQL Server (MSSQLSERVER)"



To stop named SQL Server instance use following command:

net stop "SQL Server ( instancename )"


net stop MSSQL$ instancename

SQLServer - net stop

To restart instance you need to first stop it and then start it.  On Windows, there is no one single command that can be used for this purpose.

Linux (RHEL and Ubuntu)

On Linux, we don’t have yet named instances, so all commands are executed against default instance. SQL Server can be managed using thesystemctl command.

To check the current state of SQL Server instance you can run this command:

sudo systemctl status mssql-server

To start instance run following command:

sudo systemctl start mssql-server

SQLServer - systemctl start

To stop instance run following command:

sudo systemctl stop mssql-server

SQLServer - systemctl stop

To restart instance run following command:

sudo systemctl restart mssql-server

Docker provides us a very similar set of commands.

To start container run following command:

docker start <container ID>

SQLServer - docker start

To stop container run following command:

docker stop <container ID>

SQLServer - docker stop

To restart container run following command:

docker restart <container ID>


Share it:

QuickQuestion: How to enable a trace flag on SQL Server startup?

QuickQuestion series is a series of short posts in which I answer database related questions asked by my colleagues, friends, and co-workers, mainly application developers.

Today’s question:

How to enable a trace flag on SQL Server startup?

If you want to have a certain Trace Flag enabled after every SQL Server startup, then you have to set it as one of SQL Server startup parameters. To do that you need to execute few simple steps.

  1. Open SQL Server Configuration Manager (as Administrator).
    TraceFlag - SQLServer Configuration Manager
  2. Open Properties of the SQL Server instance you want to configure.
    TraceFlag - SQLServer Configuration Manager - properties 1
  3. As a next step, go to Startup Parameters tab. Provide new startup parameter. For Trace Flag it will be -T#### (where #### needs to be replaced with Trace Flag number). Click Add button.
    TraceFlag - SQLServer Configuration Manager - startup parameters
  4. Notice that additional parameter was added to the parameters list. Click Apply button.
    TraceFlag - SQLServer Configuration Manager - startup parameters 2
  5. You will get the warning that SQL Server instance needs to be restarted in order the change takes effect.
    TraceFlag - SQLServer Configuration Manager - startup parameters 3
  6. Finally, you have to restart your SQL Server instance.
    TraceFlag - SQLServer Configuration Manager - restart

That’s it.


Share it:

SQLDay2018 – Brief introduction into SQL Server Execution Plans

Last week I had a great pleasure to speak at SQLDay 2018. For those who don’t know – it is the biggest conference focused on databases, data platform, big data, advanced data analysis and business intelligence in Poland. It has been organized for 10 years already and is a great opportunity to meet many special people. This year it was a great chance to attend workshops and sessions delivered by real SQL Server experts: Itzik Ben-Gan (b|t), Kalen Delaney (b|t), and Niko Neugebauer (b|t), and many many more…

I had an amazing occasion to present my session titled Brief introduction into SQL Server Execution Plans.

Here you can find my slide deck and materials: SQLDay2018 – Brief introduction into SQL Server Execution Plans

I also posted it on my SlideShare profile.


Share it:

24 HoP – SQL Operations Studio – slide deck

Last Thursday I had a great pleasure to present a session during 24 Hours of PASS Cross-Platform SQL Server Management. 24HOP is an exceptional online event that provides free training for database professionals. It’s 24 back-to-back hours webinar series that features a new 60-minute webinar each hour.

I had an amazing occasion to present my session about SQL Operations Studio – a New Multi-Platform tool for SQL Server Database Development, Administration, and Monitoring.

Here you can find my slide deck: SQLOps

I also posted it on my SlideShare profile.


Share it:

A list of the software I use

Two weeks ago I was blogging about The Essential SQL Server Toolkit in my stack. That reminds me of an idea I had in January to post a list of software I usually use. At that time I was forced to create such list for myself because I was changing my laptop to the new one. I decided to post it here, so next time when I will have to reinstall my laptop I will have everything already in one place. Additionally, maybe you will find something interesting here as well.

  • Microsoft Office – Word, Excel, Outlook, Powerpoint, OneNote. (link)
  • Chrome – Web browser. (link)
  • Microsoft SQL Server – I  think this doesn’t require any explanation. (link)
  • Microsoft SQL Server Management Studio – Data Management Tool. (link)
  • Microsoft SQL Operations Studio – Data Management Tool. (link)
  • Microsoft SQL Server Data Tools – SQL Server Tools for developers. (link)
  • RML Utilities – Tools to help database administrators manage the performance of Microsoft SQL Server. (link)
  • DiagManager – Graphical PSSdiag configuration manager. (link)
  • SQLNexus – Tool for PSSDiag data analysis. (link)
  • SQL Sentry Plan Explorer – Query analysis and tuning tool. (link)
  • Microsoft Data Migration Assistant – Tool for database compatibility issues detection. (link)
  • Microsoft Database Experimentation Assistant – Tool for evaluating a targeted version of SQL for a given workload. (link)
Other data platforms
  • DB Browser for SQL Lite – Data Management Tool for SQL Lite (link)
  • pgAdmin – Data Management Tool for PostgreSql. (link)
  • Neo4J – Graph Platform. (link)
  • git – Version control system. (link)
  • Git Extensions – Graphical User interface for git. (link)
  • TortoiseGit – Windows Shell Interface to Git and based on TortoiseSVN. (link)
  • Microsoft Visual Studio – Integrated Development Environment. (link)
  • Microsoft Visual Studio Code – Lightweight Code Editor. (link)
  • Notepad++ – Code editor. (link)
  • Java – Java Runtime Environment. (link)
  • .Net Framework – (link)
  • Microsoft SQL Server Data-tier Application Framework (DACFx) – (link)
  • Cisco Webex Meetings – Video conferencing and screen sharing. (link)
  • Skype – Video chat and voice calls. (link)
  • Slack – Collaboration tool. (link)
Miscellaneous – Work
  • 7-zip – Great file archiver. (link)
  • Adobe Acrobat Reader – PDF Reader. (link)
  • KeePass – Passwords manager. (link)
  • Putty – SSH and telnet client for Windows. (link)
  • Total Commander – File manager for Windows. (link)
  • WinMerge – File differencing and merging tool. (link)
  • WinScp – SFTP, SCP, and FTP client for Windows. (link)
  • Microsoft PowerBI Desktop – For creating live, interactive reports. (link)
  • Remote Server Administration Tools – For remote management rolses and features in Windows Server. (link)
  • OneDrive – File hosting service. (link)
  • VirtualBox – General purpose Virtual Machines host. (link)
  • Microsoft Visio – Diagram and charts creation. (link)
Miscellaneous – Entertainment
  • K-Lite Codec Pack – Pack of video and audio codecs. (link)
  • BESTPlayer – Video player with subtitles support. (link)
Miscellaneous – Blogging and presenting
  • GIMP – Photo/Graphic editing program. (link)
  • Pain.NET – Photo/Graphic editing program. (link)
  • ScreenToGif – Screen, webcam and sketchboard recorder with an integrated editor. (link)
  • Sizer – freeware utility that allows you to resize any window to an exact, predefined size. (link)
  • ZoomIt – screen zoom and annotation tool for technical presentations. (link)

Wow… I have much more items on my list than I expected. However, I know this list may be not complete and some very valuable application may be missing here.

Drop a comment if you found this list useful or if you think I should try out some other software you already use for a long time.


Share it:

I am speaking at 24 Hours of PASS

24HOP - logoI’m happy to announce that I have been selected to present a session during next 24 Hours of PASS. This time the main topic is Cross-Platform SQL Server Management.

24 HoP is an exceptional online event that provides free training for database professionals. It’s 24 back-to-back hours webinar series that features a new 60-minute webinar each hour. The full schedule has already been announced on last Friday.

I will have a great pleasure to present my session about SQL Operations Studio – a New Multi-Platform tool for SQL Server Database Development, Administration, and Monitoring at 06:00 UTC on April 26.

Be sure to mark your calendar for April 25-26, for this edition of 24 HoP. Registration is already open.

I’d love to see you there!


Share it:

T-SQL Tuesday #101 – The Essential SQL Server Tools in my stack

Tsql2sday logoThis month’s TSQL2sday is hosted by Jens Vestergaard (b|t) and the topic is about SQL Server tools that we, Database Administrators, Architects, and Developers use every day to work on our tasks.

It’s a great topic, isn’t it

Personally, I think that the tools we use are of great importance for our daily work. Many of you may disagree by saying that skills are much more important than tools. Of course, I completely agree with this statement. The knowledge, experience, and skills enable us to do our work even without proper tools. However, it doesn’t mean that software we use doesn’t matter. Many applications, utilities, and frameworks can automate and speed up our daily activities. Thanks to that we can achieve more in a shorter time. That’s the reason why I blog about various SQL Server tools quite often (see posts in Tools category).

The SQL Server tools I use

I don’t have a long list of fancy and unknown applications I use. I think that most of them are well known in SQL Server community. Nevertheless, I decided to describe them for you. Maybe you will find something interesting here…

Server and Database Management

sql-server-management-studio-icoThe first, and probably the most used by me tool is SQL Server Management Studio (SSMS) (download). I think I do not have to present it to anyone. It’s Swiss Army Knife tool for SQL Server specialists. Before SQL Server 2017 it was an inseparable element of every release. Since version 16, it is a separate application with a short release cycle. Every few weeks, Microsoft releases a new version and each of them delivers some new amazing features like XE Profiler, Data Discovery & Classification, Vulnerability Assessment, Import Flat File Wizard, and many, many more. I cannot imagine working with SQL Server without SSMS.


Despite the fact that SSMS is so popular, Microsoft decided to create another tool for database professionals. SQL Operations Studio (SQLOps) (download) is a new application from Microsoft designed to make our life easier. It’s a free and open source data management tool that enables you to work with SQL Server, Azure SQL DB and SQL DW from Windows, macOS, and Linux. This light-weight multi-platform solution can be used for SQL Server database development, administration, and monitoring. I described it more in details in this post.


T-SQL Source Code Management

sql-server-data-tools-icoFor database source code management, I use SQL Server Data Tools (SSDT) (download) and Git for Windows (download). Thanks to SSDT we can create SQL Database projects in the same way you can create .NET projects in Visual Studio. These projects can be built and validated, and then the compiled artifact in the form of a DACPAC file can be easily deployed against the target database.


To automate the DACPAC deployment process my team uses sqlpackage.exe from Data-Tier Application Framework (DACFx) (download) wrapped in our own PowerShell module. We decided to create our own wrapper because this gives us required flexibility and makes our database deployment process more streamlined.

For text/SQL files

notepad-plus-plus-icoSSMS and SSDT are great and very powerful SQL Server tools for work with *.sql files. However, sometimes I find that I don’t need to use such big and complex tool for performing easy and quick tasks on text/SQL files. It may include things like opening file just for a quick view or quick search. I used to use Notepad++ (download) for such kind of activities, but recently I’m trying to make myself more familiar with Visual Studio Code (download).


visual-studio-code-icoVisual Studio Code is a lightweight and extensible multi-platform source code editor which can be used on Windows, macOS, and Linux. Microsoft puts a lot of effort in the development of this solution. It comes with a built-in support for JavaScript, TypeScript, and Node.js and has a lot of extensions for other languages (such as T-SQL, C#, C++, Java, Python,…).


winmerge-icoFor text file comparison I use WinMerge (download). It is a free and an Open Source differencing and merging tool for Windows. It can compare both folders and files, presenting differences in a visual text format that is easy to understand and handle.


Database Unit Tests

tsqltTo test database code I use tSQLt (download). tSQLt is a free and opensource database unit testing framework for Microsoft SQL Server, completely written in T-SQL and .NET CLR. Additionally, besides the long list of available assertions, it also has the great and rare functionality to mock various database objects. In my opinion that makes it better then tests in SSDT.

In addition to the above, I recently started to use SQLCover (download) created by Ed Elliott (b|t). It’s one more free and open source solution, this time for unit tests code coverage report generation. It’s amazing how well it works.


Community scripts/tools

Besides all of the above-mentioned SQL Server tools, I have my favorite set of well-known T-SQL scripts or procedures I use commonly for troubleshooting. The first and probably most-known solution is sp_whoisactive (download) procedure from Adam Machanic (b|t). It’s something like a powerful combination of sp_who2, Activity Monitor, and many other diagnostic queries based on DMVs. If you’ve never used it before, then you should try it now!

first-responder-kitOther scripts I use quite often are stored procedures from Brent Ozar ULTD First Responder Kit (download). This bundle consists of such tools like sp_Blitz, sp_BlitzFirst, sp_BlitzCache, and a few others also very useful.

Troubleshooting Tools

In very difficult situations, when above scripts are not enough for issue troubleshooting, I use PSSdiag (download) and SQLNexus (download). Both were developed in Microsoft as side projects mainly used by SQL Server Customer Support Service and Product Support Service teams. Now, public versions are free and opensource and can be used by everyone.

PSSdiag is a data collector utility that can capture various interesting data sets, counters, and metrics. For example:

  • Event Logs
  • PerfMon counters
  • Server configuration
  • Error Logs
  • Profiler Trace / XE Session
  • Blocking information
  • Query statistics
  • and many others…

If that would not be enough it also can be extended by custom collector scripts. This gives the user the ability collect all the necessary information.

SQLNexus analyses the data collected by PSSdiag and generates very detailed reports that describe monitored SQL Server state and health. They are invaluable in troubleshooting SQL Server issues.

In case you’re interested in possibilities that these tools give, I encourage you to read my other blog post describing PSSdiag and SQLNexus use case.

SQL Server tools that are on my check-it-out list

In addition to all of these tools I already use, there are others I still want to try out.

dbatools-icodbatools (download) is a PowerShell module with more than 300 SQL Server administration, best practice and migration commands included. Thanks to the huge number of contributors from SQL Server community it’s growing and getting better and better.

dbachecks-icoThe same amazing group of people created dbachecks (download) PowerShell module. It’s a solution for automated environment validation. It’s based on Pester and has already more than 80 checks implemented.


dbareports-icoLast but not least is dbareports (download). It uses PowerShell, T-SQL and SQL Agent to gather information about your SQL Server estate. It also comes with beautiful SSRS reports and PowerBi and Cortana Integration.

All of these solutions wouldn’t exist without Chrissy LeMaire (b|t) and Rob Sewell aka SQL DBA with A Beard (b|t) who started all of this! Thanks to their and SQL Server community effort we have a plenty of great SQL Server tools for our use.


Share it: