microsoft / go-sqlcmd

The new sqlcmd, CLI for SQL Server and Azure SQL (winget install sqlcmd / sqlcmd create mssql / sqlcmd open ads)
https://learn.microsoft.com/sql/tools/sqlcmd/go-sqlcmd-utility
MIT License
334 stars 58 forks source link

Register sqlcmd:// URL protocol when installing sqlcmd with package managers (.msi etc.), add --generate-url to `sqlcmd create` #311

Open stuartpa opened 1 year ago

stuartpa commented 1 year ago

Once #310 is implemented, sqlcmd users will be able to share T/SQL repro scripts with their SQL Server configuration (version, database(s) etc.) with a single command-line, and have it pop up in Azure Data Studio e.g:

sqlcmd create mssql --using https://aka.ms/AdventureWorksLT.bak --open ads --file https://tiny.url/my-repro.sql

When asking for help on twitter using the #SQLHelp hash tag, or interacting with CSS, it would be convenient to be able to share this repro in a single URL which will run identically on another persons machine (presume the http(s) links are equally accessible). A --generate-url flag would be added to sqlcmd-create (default to true I presume), this generates a web friendly URL and outputs to console at the end of the create, e.g.

sqlcmd://c3FsY21kIGNyZWF0ZSBtc3NxbCAtLXVzaW5nIGh0dHBzOi8vYWthLm1zL0FkdmVudHVyZVdvcmtzTFQuYmFrIC0tb3BlbiBhZHMgLS1maWxlIGh0dHBzOi8vdGlueS51cmwvbXktcmVwcm8uc3Fs

Copying this link, and pasting it into a local machine run window, would re-create the repro environment locally, with the same version of SQL Server (presuming a --tag was included), database restored, and load the .sql script in ADS.