How to Use Default and Custom Widgets in SQL Server Operations Studio

There are already a number of articles and blog posts that reveal the benefits of the SQL Operations Studio tool. The demand created across the software and the related tools are relatively unimaginable than ever before. The trend and growth will continue to increase in the upcoming days.

The graphical representation is in the vogue today. Visualizing data helps us to better understand this and to make decisions. It’s no wonder that data visualization continues to attract a growing number of users. The development of any toolset could provide opportunities to speed up the software development lifecycle process.

This article demonstrates the advantages of using custom SQL queries or complex T-SQL to provide a great insight into the database and explains how one can use this insight to build custom widgets. In this case, the SQL Operations Studio Widget is a customized piece of the code to personalize the SQL Server Dashboard for effective management of SQL instances.

The more time you spend working with the tool, the more you realize that this intelligent light-weight cross-platform application can create interesting things.

In this article, you will learn the following:

  • Introduction to SQL Operations Studio
  • How to run a custom SQL query and view it as a chart
  • How to use default and custom widgets
  • Various panes and options in SSOS
  • Explain the different chart options
  • Create a custom insight
  • Details to define a custom widget step by step
  • And more…

SQL Operations Studio is a cross-platform lightweight tool for data management and administration, modern database development and operations that support SQL Server, Azure SQL DB and SQL DW from Windows, macOS, and Linux. SQL Ops Studio is a tool for both database developers and database administrators.

A widget is a small block such as a pie chart, which represents the data as a visual logical image and gives an overview to a user.

Widgets can be placed into three broad categories:

  • Standard widget
  • Database widget
  • Server widget

The standard widget can be further classified into three types:

  1. Tasks-widget
  2. Explorer-widget
  3. Insights-widget

The database widgets are divided into:

  1. Table-space-db-insight
  2. Query-data-store-db-insight
    1. The query store feature provides an insight into the query plan choices and its performance.
    2. This requires the QUERY_STORE parameter to be enabled on a database. Use the following query to enable the QUERY_STORE option.

The server widget insights are:

  1. Backup-history-server-insight
  2. All-database-size-server-insight

How to add a default database-server insight widget to the dashboard

We can add insight widgets such as “table-space-db-insight”, “query-data-store-db-insight”, “Backup-history-server-insight“ and “All-database-size-server-insight” to “dashboard.database.widgets” in user settings.

  1. To open user settings, press Ctrl+Shift+P. 
  2. In the command palette that appears, type Open User settings.
  3. In the User settings search box, type database to locate a database widget.
  4. To customize the database widget dashboard, click the edit icon to the left of the text and select the Copy to Settings option.
  5. The database dashboard settings are copied to the right half of the user settings.
  6. Now, edit the JSON tags with the corresponding entries. These properties will appear on the dashboard.database.widgets settings.

    For example, copy and paste the following JSON items as shown above into the default database insight widgets.
  7. Press Ctrl+S to save the user settings.
  8. To open the database dashboard, right-click the database and click Manage.
  9. You can see the default database widgets dashboard. In this case, the QDS is not enabled on the database. Hence, the output displays “QDS is not enabled”.

How to add a custom database insight widget to the dashboard

The first step in preparing the custom widget is to create a SQL query that can be a simple query or a complex T-SQL script.  In this case, we are going to work with complex database growth statistics or T-SQL script. You can find the script in the Appendix (A) section.

The steps are very simple and interesting too! Let’s follow them to create a custom database widget.

  1. On the query pane of the new query window (Ctrl+N), prepare the SQL query.
  2. Run (F5) the SQL query and validate the result in the results pane.
  3. In the results pane, click View as chart to create insights.
  4. Customize the chart according to your requirements. We can adjust the output by changing the orientation, adding a legend or by choosing the chart type. It’s very simple to customize the output to make it look more meaningful.
  5. Now, click the Create Insight button on Chart Viewer to generate the JSON.
  6. Save the query and call it c:\SQL2014\dbGrowthSqlQuery.sql.
  7. To add the JSON data to the database dashboard widget, copy the code into User Settings.
  8. To open user settings, press Ctrl+Shift+P.
  9. In the search box, type Open User settings.
  10. Search for the keyword – “database”.
  11. Select database.widgets.
  12. On the split screen, add the JSON data.
  13. Modify or customize the highlighted JSON tags.

  14. Press Ctrl+S to save your user settings.
  15. Open the database dashboard by right-clicking the database and selecting Manage.
  16. Now, we can see the dashboard representing the database growth statistics.

The other advantage is that you can remove the columns without the need to redefine the code.

That’s all for now!

Wrapping Up

In this article, we discussed how to configure a various default database and server widget insights. Also, the article highlights the steps to add a custom SQL as a part of the dashboard. We saw how simple it is to define and customize the dashboard. While SSMS is still the de-facto tool compatible with SQL Server instances, it’s more of an integrated environment. When you just want to play with SQL or create light widgets, SQL Operations Studio has several advantages over the SQL Server Management Studio.

As it’s available on Linux and easy to be integrated with PowerShell, it’s becoming a promising SQL toolset for many developers and administrators alike.

What do you think? Give it a download if you haven’t, and feel free to comment below.

References

https://docs.microsoft.com/en-us/sql/sql-operations-studio/tutorial-build-custom-insight-sql-server

https://docs.microsoft.com/en-us/sql/sql-operations-studio/tutorial-qds-sql-server

https://docs.microsoft.com/en-us/sql/sql-operations-studio/tutorial-table-space-sql-server

Appendix (A)

The T-SQL  shows how to fetch the growth metrics of all the databases.

Code
 

Prashanth Jayaram

Prashanth Jayaram

Prashanth Jayaram is working as a DB Manager for a leading MNC, Database Technologist, Author, Blogger, Automation Expert, Technet WIKI Ninja, and Powershell Geek.
Prashanth Jayaram
1,129 views