DB/MsSQL

From Ever changing code
< DB
Jump to navigation Jump to search

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