Site icon TheWindowsUpdate.com

go-sqlcmd v1.0 – Create, Connect to, and Query SQL Server

This post has been republished via RSS; it originally appeared at: New blog articles in Microsoft Community Hub.

If you’re reading this, you’ve probably used sqlcmd to connect to a SQL Server or Azure SQL Database and query it. Chances are you’ve also used a modern CLI like Azure az or Kubernetes kubectl to create and manage resources. Our open-source sqlcmd combines both into one amazing tool, and today we are announcing v1.0! 

 

What’s New

 

Let’s start with the most important feature - you’ll still be able to use most of the sqlcmd commands you’re used to. You can connect to a database, run queries, and output information.

 

The new sqlcmd offers more Azure Active Directory authentication options, such as ActiveDirectoryManagedIdentity and ActiveDirectoryServicePrincipal.

 

The biggest change is the new functionality. First, you can download sqlcmd from your favorite package manager - winget, brew, apt, yum, choco. After it’s downloaded and installed,

sqlcmd create mssql 

will create a SQL Server container running on your computer. (You’ll need a container runtime like Docker or Podman. But don’t worry - if you don’t have one, you’ll be prompted to install one.) Use

sqlcmd create mssql get-tags 

to see a list of SQL Server releases to choose from. That’s right - one line of code and you have a fully-functional version of SQL Server to connect to and use.

 

You can also create an instance with a database from a backup by using the command 

sqlcmd create mssql --using https://url.com/backup.bak 

That’s right - one command to create the instance and restore a backup.

 

If you want to query the new instance and database from within the command line, you can run 

sqlcmd query "SELECT … FROM …" 

It will query the database without you having to make a separate connection.

 

Do you want more capabilities, like an object explorer or management options? Run 

sqlcmd open ads 

and, if Azure Data Studio is installed on your computer, it will open with your connection context!

 

Let’s Go!

 

Why is this revolutionary? Our new sqlcmd is based on the Go language, which has a single binary when compiled. We built it on top of the go-mssqldb driver, demonstrating our commitment to use modern languages and open-source our tools. It’s able to be run on any OS (Windows, Mac, or Linux) and on both AMD64 and ARM64. It’s also open-source, and you can contribute ideas, log bugs, or check in new features via PR in the GitHub repository.

 

Go ahead (no pun intended) - download sqlcmd today, create your container, open it in Azure Data Studio, and provide feedback to us!

 

winget install sqlcmd sqlcmd create mssql sqlcmd open ads

 

 

Exit mobile version