One of my clients asked few interesting questions during my performance tuning consultation. If you are interested, you can check more details here SQL Server Performance Tuning and Optimization. In this blog, we would discuss how to execute the query without SQL Server Management Studio (SSMS).
For those who are experts in SQL Server, the question sounds very funny but this blog is for those who are a newbie to SQL Server. Based on your level of understanding, you can proceed.
After hearing the question, I asked my client about the reason for this. They told that their security team asked to uninstall SQL Server Management Studio from Server and run query only from remote machines. Now, remote machines don’t have SSMS installed.
There are various solutions to this problem. If there is a need for UI based tool to do some basic tasks from UI and execute all kind of queries then SQL Server Operations Studio can be used. This tool can be used from Windows, Mac, and Linux machines. Here is the link to download the tool.
If there is no need for user interface and the command line is OK then we can use SQLCMD tool. This tool can be downloaded by searching “SQL Server feature pack” in any search engine. Here are the results as of today in google.
Based on your need, you can choose the version. I always go with the latest one because it can connect to old versions also. Once we go to download page, there are many downloads available. We need below two.
- Microsoft ODBC Drivers for Microsoft SQL Server (msodbcsql.msi)
- Microsoft Command Line Utilities for SQL Server (SqlCmdLnUtils.msi)
After downloading and installing above two (in the same sequence), you should be able to connect to local or remote SQL Server and execute queries using SQLCMD tool. You can read more about this tool here.
Hope this blog would help some newbie struggling to find the answer to simple question.
Reference: Pinal Dave (https://blog.sqlauthority.com)