{"id":76365,"date":"2017-12-18T10:47:55","date_gmt":"2017-12-18T10:47:55","guid":{"rendered":"https:\/\/www.red-gate.com\/simple-talk\/?p=76365"},"modified":"2021-05-11T15:57:18","modified_gmt":"2021-05-11T15:57:18","slug":"walk-around-sql-operations-studio","status":"publish","type":"post","link":"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/tools-sql-server\/walk-around-sql-operations-studio\/","title":{"rendered":"A Walk Around SQL Operations Studio"},"content":{"rendered":"<div class=\"note\">\n<p><em>NOTE: Microsoft has changed gears on this tool. Instead, they have released Azure Data Studio for Windows, macOS, and Linux. You can download it <a href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/azure-data-studio\/download?view=sql-server-2017\">here<\/a>.<\/p>\n<p><\/em><\/div>\n<p>&nbsp;<\/p>\n<p>As a data person you\u2019ve likely looked, with some envy, at the cool new multiplatform tools Microsoft has released for your developer coworkers. <a href=\"https:\/\/code.visualstudio.com\/\">Visual Studio Code<\/a>, or VS Code, is an open source application which will run on Windows, macOS, and Linux, allowing software development for a variety of languages. You\u2019ve probably thought, \u201cHey, where\u2019s OUR multiplatform tool for working with data?\u201d Well, have I got good news for you!<\/p>\n<p>Microsoft has just released SQLOPS \u2013 SQL Operations Studio \u2013 in preview mode. Built on top of VS Code, it is designed to manage your SQL Server from multiple platforms. SQLOPS runs on Windows, macOS, and Linux. Best of all, it is absolutely free to use.<\/p>\n<h2>Downloading SQLOPS<\/h2>\n<p>Before you rush off and download it, there is a word that needs to be stressed. <strong>PREVIEW<\/strong>. The tool is essentially in beta. This means there will be features that might not be quite complete, and you will likely encounter bugs. You are using this at your own risk, and you should expect frequent updates to the product. As a result, installation on your production systems is probably not a good idea.<\/p>\n<p>As you will see, there are some features that make it worth looking at now. Using the tool is simple, and low risk, as technically there is no true install. You simply download it, extract the files, and start using it. To download, just go to <a href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/sql-operations-studio\/download\">https:\/\/docs.microsoft.com\/en-us\/sql\/sql-operations-studio\/download<\/a> or you can use the shortcut <a href=\"http:\/\/bit.ly\/sqlops\">http:\/\/bit.ly\/sqlops<\/a>. When you do, you\u2019ll see this on the page:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"981\" height=\"748\" class=\"wp-image-76367\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/12\/word-image-12.png\" \/><\/p>\n<p>From here, select the version appropriate to your operating system. Once it\u2019s downloaded, installation is very simple.<\/p>\n<h2>Installation on a Mac<\/h2>\n<p>To install on a Mac, be sure to navigate to the site and download the file. Once the file is downloaded, simply select <em>Open in Finder<\/em> and unzip the file.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1797\" height=\"543\" class=\"wp-image-76368\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/12\/word-image-13.png\" \/><\/p>\n<p>With the downloads folder open, simply drag and drop (or copy and paste) into the <em>Applications<\/em> folder.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"582\" height=\"334\" class=\"wp-image-76369\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/12\/word-image-14.png\" \/><\/p>\n<p>Then, just double click on the SQL Operations Studio icon to open it. (Note this Mac has the <em>Show file extensions<\/em> option enabled, yours may not show the <strong>.app<\/strong> extension at the end. It\u2019s still the same program.)<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"584\" height=\"337\" class=\"wp-image-76370\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/12\/word-image-15.png\" \/><\/p>\n<p>And there you go, you are ready to connect to your SQL Server!<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1412\" height=\"882\" class=\"wp-image-76371\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/12\/word-image-16.png\" \/><\/p>\n<h2>Installation on Windows<\/h2>\n<p>Installation on Windows is even simpler. First, you will create a folder on your hard drive that will hold the application. Unlike most windows applications, SQLOPS does not have a traditional installer. On this Windows installation, <strong>C:\\SqlOps<\/strong> was created.<\/p>\n<p>Once you have it downloaded, just go to your downloads folder. Double click on the sqlops-windows-0.23.6.zip file (note the file name will change as new versions are released, use the file name that you downloaded). It will open another folder with the contents of the ZIP file.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"728\" height=\"168\" class=\"wp-image-76372\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/12\/word-image-17.png\" \/><\/p>\n<p>Drag and drop (or copy and paste) the <strong>sqlops-windows<\/strong> folder to your <strong>C:\\SqlOps<\/strong> (or wherever you created your target folder). Once there, navigate to the <strong>sqlops-windows<\/strong> folder.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"968\" height=\"398\" class=\"wp-image-76373\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/12\/word-image-18.png\" \/><\/p>\n<p>Double-click <strong>sqlops.exe<\/strong> to run it. If the connection window doesn\u2019t appear when you open SQLOPS, simply click on the <em>New Connection<\/em> icon.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1019\" height=\"770\" class=\"wp-image-76374\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/12\/word-image-19.png\" \/><\/p>\n<p>Fill out the connection information and click <em>Connect<\/em>. Unlike other tools, this version doesn\u2019t provide a dropdown list of databases, so you must type in a valid database name.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1011\" height=\"762\" class=\"wp-image-76375\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/12\/word-image-20.png\" \/><\/p>\n<h2>Installation on Linux<\/h2>\n<p>Installation on Linux turns out to be almost as simple. The download page has a bash script you can run to extract the files once they have been saved to your system. Be aware that depending on the version of Linux you run, there may be additional dependencies you have to install. Due to the wide variety of Linux distributions there are too many combinations to attempt to document here; just follow the instructions on the download site for your version of Linux.<\/p>\n<h2>The SQLOPS Interface<\/h2>\n<p>By this point, you\u2019ve installed SQLOPS on your operating system and have filled out the connection information. Once you are connected to your server, you should see something like this (note the numbers were added to enable discussion of the layout):<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1146\" height=\"981\" class=\"wp-image-76376\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/12\/word-image-21.png\" \/><\/p>\n<p>The area denoted by the red number 1 is the <em>Servers<\/em> pane, also known as the <em>Object Explorer<\/em> in some online documentation. Expanding the server branch (in this example <em>localhost<\/em>), then <em>Databases<\/em>, will present a list of the databases. The <em>Object Explorer<\/em> serves the same function here as it does in SSMS (SQL Server Management Studio). It provides a way to navigate the various objects on your SQL Servers, drilling down and providing menus to launch other operations like editing data or executing queries.<\/p>\n<p>In SSMS, when you connect to a server the area to the right is empty. With SQLOPS though, you can see a nice dashboard. The area in green, number 2, is the dashboard header. It gives an overview of the server including the SQL Server version, edition of SQL, computer name, and OS (Operating System) version.<\/p>\n<p>The next area, number 3, are shortcuts to common tasks. At the server level, the three most common tasks are restoring a database, configuring your server, and creating a new query. As later versions of SQLOPS are developed, you may see other tasks in this area as new functionality is brought to the application. Below the tasks pane is area 4, which shows the backup status of your various databases.<\/p>\n<p>To the right is area 5, the search pane. This provides a quick way to find various objects on your server. Just begin typing and it will narrow the list of databases to match what you are keying in.<\/p>\n<p>Finally, the very bottom is area 6. This shows a graph comparing the sizes of your various databases. This screen capture is cut off due to size limitations, but it just allows you to get a quick at a glance comparison of size between your various databases.<\/p>\n<p>On the very left is a big gray bar with some icons. Let\u2019s take a quick look at it.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"326\" height=\"330\" class=\"wp-image-76377\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/12\/word-image-22.png\" \/><\/p>\n<p>The top brings up the panel you\u2019d already seen, the <em>Servers<\/em> (aka the Object Explorer). The next button down is the <em>Task History<\/em>. If you had performed any backups, restores, or other similar tasks you could reference them in this area. Below this is the <em>Explorer<\/em> pane. The <em>Explorer<\/em> pane has a list of all open files in the SQLOPS editor. It offers some useful options, so let\u2019s take a closer look at it.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1061\" height=\"534\" class=\"wp-image-76378\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/12\/word-image-23.png\" \/><\/p>\n<p>The <em>Explorer<\/em> pane contains list of all open files. To the right of the file name is the full path to the file. Right clicking on the file provides a rich context menu. Most of the options, such as <em>Save<\/em> and <em>Close<\/em>, are pretty obvious in their functionality but a few do warrant further explanation.<\/p>\n<p><em>Open to the Side<\/em> opens the file in split screen, so you can compare two files side by side in SQLOPS. <em>Reveal in Explorer<\/em> opens up an Explorer window in your computers operating system. <em>Open in Terminal<\/em> opens up a terminal window in the lower half of the SQLOPS application, by default it is PowerShell, but it can also be changed to a Command Prompt (CMD), or a BASH terminal. This may vary by operating system, for example on macOS you wouldn\u2019t have the option for a CMD window. You can also open a terminal window by using the View menu in the toolbar, and selecting <em>Integrated Terminal<\/em>.<\/p>\n<p>The <em>Search<\/em> pane brings up a pane that can be used to search, or search and replace, text in the current editor window. Below this is the <em>Source Control<\/em> pane, this allows you to manage your various files within your source code control system.<\/p>\n<p>Way down at the bottom is a big gear icon. This allows you to alter the various settings of SQLOPS, such as the keyboard shortcuts, color theme, and more.<\/p>\n<h2>Running Queries<\/h2>\n<p>At this point you should have a good overview of the SQLOPS interface. Let\u2019s start doing some actual work and do one of the most common things, running a query. From the <em>Servers<\/em> pane, expand your databases, then expand one database, then the tables for that database. For this example, I\u2019ll be using the WideWorldImportersDW database.<\/p>\n<p>NOTE: WideWorldImporters is a new sample database introduced with SQL Server 2016. If you don\u2019t have it, you can download the <a href=\"https:\/\/github.com\/Microsoft\/sql-server-samples\/releases\/tag\/wide-world-importers-v1.0\">backup file<\/a> or <a href=\"https:\/\/github.com\/Microsoft\/sql-server-samples\/tree\/master\/samples\/databases\/wide-world-importers\">source code<\/a> from GitHub. There are multiple databases as part of the sample, for this article we\u2019ll be using the data warehouse version (WideWorldImportersDW).<\/p>\n<p>Right click on a table, and chose the <em>Select Top 1000<\/em> option.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"344\" height=\"301\" class=\"wp-image-76379\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/12\/word-image-24.png\" \/><\/p>\n<p>If you\u2019ve worked with SSMS, the following screen should look familiar. Like SSMS, the query is at the top, and the results at the bottom. Unlike SSMS, which has the <em>Results<\/em> and <em>Messages<\/em> on separate tabs, SQLOPS places the messages just below the results. From here you can make changes to the query and re-run it, save your query, and perform other actions you\u2019d normally do with a SQL file. There are two areas though that should be called out. The first is the <em>Explain<\/em> button, highlighted in red in the above image.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"763\" height=\"670\" class=\"wp-image-76380\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/12\/word-image-25.png\" \/><\/p>\n<p>Clicking <em>Explain<\/em> brings up the query plan. While this is of course possible in SSMS, SQLOPS makes it much more convenient to run. Hovering over any item in the query plan brings up more details about that item.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"748\" height=\"236\" class=\"wp-image-76381\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/12\/word-image-26.png\" \/><\/p>\n<p>The other area you should notice is to the right of the results, highlighted in green in the image showing the query results. From top to bottom, the first three are <em>Save as CSV<\/em>, <em>Save as JSON<\/em>, and <em>Save as Excel<\/em>. This is a great addition, allowing you to easily save your data for other purposes.<\/p>\n<p>The final option is <em>View as Chart<\/em>. For the data in the previous <em>SELECT 1000<\/em> query the option won\u2019t provide anything meaningful, so let\u2019s look at an example that will. In the <em>Servers<\/em> pane, right click on your database and pick <em>New Query<\/em>. Then, paste in the query below, assuming you are using the WideWorldImportersDW sample database.<\/p>\n<pre class=\"theme:ssms2012-simple-talk lang:tsql decode:true\">SELECT d.[Calendar Year]\r\n     , SUM(s.[Total Including Tax])\r\n  FROM [WideWorldImportersDW].[Fact].[Sale] s\r\n  JOIN [WideWorldImportersDW].[Dimension].[Date] d\r\n    ON s.[Invoice Date Key] = d.[Date]\r\n GROUP BY d.[Calendar Year]\r\n ORDER BY d.[Calendar Year]\r\n<\/pre>\n<p>Run the query, and view the results at the bottom. Now press the <strong>chart button<\/strong>, as indicated by the giant red arrow.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"783\" height=\"237\" class=\"wp-image-76382\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/12\/word-image-27.png\" \/><\/p>\n<p>Ta-da! A chart which neatly summarizes the results of your query appears. If you expand the <em>Chart Type<\/em> on the right, you\u2019ll see many different charts are available. Play with it to see what the results are for the various types. One thing to be aware of, the chart viewer works best when there are a limited number of categories, as in this example, the years. If you have a lot of categories, for example hundreds of customers, the chart will be unreadable and not very useful.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"763\" height=\"376\" class=\"wp-image-76383\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/12\/word-image-28.png\" \/><\/p>\n<h2>Help Writing Your Queries<\/h2>\n<p>All of us have SQL syntax we use on a regular basis. But what about times when you are writing SQL queries that you don\u2019t normally run? Often, you wind up doing internet searches to remind yourself of the correct syntax, or hunt for previous scripts where you used a similar query. Well SQLOPS has a great tool to help you out. Return to the <em>Server<\/em> pane, right click on your database, then pick <em>New Query<\/em>. In the empty editor, type <strong>sql<\/strong>, and see what pops up!<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"568\" height=\"285\" class=\"wp-image-76384\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/12\/word-image-29.png\" \/><\/p>\n<p>SQLOPS has an extensive library of snippets built in. A snippet is a code template that has the basics for a command. Let\u2019s narrow it down some, keep typing adding <strong>Se<\/strong> after the code you have already typed.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"571\" height=\"246\" class=\"wp-image-76385\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/12\/word-image-30.png\" \/><\/p>\n<p>As you can see, the snippet popup narrows itself down to those options with SE in the name. Since sqlSelect is already highlighted, just hit the <strong>TAB<\/strong> key on your keyboard.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"666\" height=\"120\" class=\"wp-image-76386\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/12\/word-image-31.png\" \/><\/p>\n<p>You\u2019ll see <strong>TableOrViewName<\/strong> is highlighted. Just type <strong>City<\/strong>, and you\u2019ll see it updates both the <strong>TableOrViewName<\/strong> in the comment, as well as in the query itself. Hit the <strong>TAB<\/strong> key, which will highlight <strong>SchemaName<\/strong>. Simply type in <strong>Dimension<\/strong>, and it will also update both the comment and the query. From here you can edit your query normally, adding to the <strong>WHERE<\/strong> clause (or removing it), adding a <strong>GROUP BY<\/strong>, and whatever else you\u2019d like to do. Then, you can run your query. This provides a very efficient way of writing your queries, especially for query types you don\u2019t work with on a regular basis.<\/p>\n<h2>Peeking into Your Database<\/h2>\n<p>When writing queries, a common need is to know more information about the objects you\u2019re working with. Let\u2019s return to the previous example, where we generated a <strong>SELECT *<\/strong> query. Now you want to limit the query to a few columns. Sure, you could jump over the Server pane, and navigate down to the database, then the table, then the columns. It would be much more efficient though if you could jump right to the definition of the object. That\u2019s where the peek functionality comes into play.<\/p>\n<p>In the query editor, put your cursor on the table name, and right click. On the menu, pick <em>Peek Definition<\/em>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"580\" height=\"305\" class=\"wp-image-76387\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/12\/word-image-32.png\" \/><\/p>\n<p>A small window opens under the item you peeked. The definition for the table appears within. You can copy columns out of the window, as well as review the definition. Peek works for more than just tables, it can also be used with stored procedures, functions, and other similar objects. To close the peek window, just click on the <em>x<\/em> in the upper right of the peek window.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"781\" height=\"320\" class=\"wp-image-76388\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/12\/word-image-33.png\" \/><\/p>\n<p>The other option is <em>Go to Definition<\/em>. This will open a new tab with the definition of the object (in this example the City table). From there you can alter, run, or anything else you\u2019d normally do in a SQL window.<\/p>\n<h2>Summary<\/h2>\n<p>In this article, we explored SQLOPS \u2013 SQL Server Operations Studio. SQLOPS is the new open source, multiplatform tool for working with SQL Server. We began by seeing how easy it is to install, then showed the interface. Next, we looked at some common tasks such as editing queries, then reviewed the cool snippets feature. Finally, we looked at how to \u2018peek\u2019 into your database. Although still in preview, SQLOPS already has many features that make it a worthy addition to your toolkit.<\/p>\n<p>If you\u2019d like to see the actual code behind SQLOPS, you can get it from Microsoft\u2019s github site, <a href=\"https:\/\/github.com\/Microsoft\/sqlopsstudio\">https:\/\/github.com\/Microsoft\/sqlopsstudio<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>SQL Server Management Studio has been the default tool for working with SQL Server for over a decade. It\u2019s not, however, compatible with any operating system outside of Microsoft Windows. SQL Operations Studio (SQLOPS), the open source program originally called \u2018Project Carbon\u2019, is now available for users of Linux and macOS as well as Windows. Robert Cain demonstrates the features of SQLOPS.&hellip;<\/p>\n","protected":false},"author":316962,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[143532],"tags":[],"coauthors":[52865],"class_list":["post-76365","post","type-post","status-publish","format-standard","hentry","category-tools-sql-server"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/76365","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/users\/316962"}],"replies":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/comments?post=76365"}],"version-history":[{"count":5,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/76365\/revisions"}],"predecessor-version":[{"id":83763,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/76365\/revisions\/83763"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=76365"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/categories?post=76365"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=76365"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=76365"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}