Visual Studio Code and T-SQL on SQLServeronLinux

As a follow up blog on working with SQL server on Linux(Original Blog - http://learningdatabaseguy.blogspot.com.au/2017/11/setup-sql-server-instance-on-linux-on.html), I have decided to use Visual Studio Code (https://code.visualstudio.com/) to connect to SQL server instance on Linux running on docker.

To refresh our minds, we can use below command to check the SQL server running process: 

192-168-1-10:~ ashwi$ docker ps
CONTAINER ID        IMAGE                                   COMMAND                  CREATED STATUS              PORTS                    NAMES
187d5a935fe6        microsoft/mssql-server-linux:2017-GDR   "/bin/sh -c /opt/m..."   21 hours ago Up 21 hours         0.0.0.0:1401->1433/tcp   practical_kirch
192-168-1-10:~ ashwi$ docker ps
CONTAINER ID        IMAGE                                   COMMAND                  CREATED             STATUS              PORTS                    NAMES

187d5a935fe6        microsoft/mssql-server-linux:2017-GDR   "/bin/sh -c /opt/m..."   6 days ago          Up 6 days           0.0.0.0:1401->1433/tcp   practical_kirch

There are some prerequisite softwares needed before VS Code can be installed on Mac.

We have used the steps mentioned in the below blog to install all these
We need the following softwares:

  1. In order for VS Code on the Mac to connect to SQL Server (on a Linux VM, in a Docker container, and possibly elsewhere), you need a current version of OpenSSL.
     
  2. The easiest way I've found to install OpenSSL is using the package manager Homebrew, though if you search you can find more tedious and elaborate ways.
     
  3. In order to install Homebrew, you'll need Apple's command line tools. For this we'll install Xcode, though if you prefer, there are ways to avoid that.

We'll work backwards through that list before moving on to Docker. First…
1. Install XCode
2. Install Homebrew
3. Install OpenSSL
Detailed steps @ https://blogs.sentryone.com/aaronbertrand/vs-code-mac-sql-linux-docker/

One VSCode is installed, we follow the below steps to interact with the SQL server instance:
1. Install the 'mssql' extension needed to connect to the SQL server
2. Connect to the SQL server, by Creating a new Connection profile



As the SQL server instance is running on my local docker, the server name connection properties will be 127.0.0.1,1401 (port=1401). We also provided SA login and password for the connection.

3. Once connected successfully, you should be able to see below success icon at bottom right:






4. One incredibly helpful feature of the mssql extension for VSCode is Intellisense. I have given couple of below examples:


CREATE DATABASE

USE DATABASE 

SELECT COLUMNS FOR A QUERY


All in all, I found VSCode a very handy tool to interact with SQL server on Linux.

Reference link:
https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-develop-use-vscode

Next stop, trying to work with SQL server Operations Studio (https://docs.microsoft.com/en-us/sql/sql-operations-studio/what-is
) to connect to SQL Server on Linux till we wait and hope that some day we can get SSMS 2017 installed directly on Mac 😊







Comments

Popular posts from this blog

Setup SQL Server instance on Linux on Docker