Difference between revisions of "DB/MsSQL"

From Ever changing code
< DB
Jump to navigation Jump to search
Line 1: Line 1:
= [https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup-tools?view=sql-server-ver15 Install sqlcmd and bcp the SQL Server command-line tools on Linux] =
<source lang=bash>
# Import the public repository GPG keys.
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
# Register the Microsoft Ubuntu repository.
curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list
# Update the sources list and run the installation command with the unixODBC developer package.
sudo apt-get update
sudo apt-get install mssql-tools unixodbc-dev
# echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
/opt/mssql-tools/bin/sqlcmd -?
</source>
= Operational commands =
Show current session process ID. In Azure Data Studio, each query window has a different SessionProcessID
Show current session process ID. In Azure Data Studio, each query window has a different SessionProcessID
<source lang=sql>
<source lang=sql>

Revision as of 15:39, 20 August 2021

Install sqlcmd and bcp the SQL Server command-line tools on Linux

# Import the public repository GPG keys.
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
# Register the Microsoft Ubuntu repository.
curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list
# Update the sources list and run the installation command with the unixODBC developer package.
sudo apt-get update 
sudo apt-get install mssql-tools unixodbc-dev
# echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
/opt/mssql-tools/bin/sqlcmd -?


Operational commands

Show current session process ID. In Azure Data Studio, each query window has a different SessionProcessID

SELECT @@SPID

Azure MsSQL

Due to architecture you cannot use USE statement.


References