MSSQL How to

How to set mssql server name for a mssql container

with run -h sets computer name, where is —name does not change server name
you can see it in

SERVERPROPERTY('ComputerNamePhysicalNetBIOS')+' '+SERVE^CROPERTY('MachineName')+' '+SERVERPROPERTY('ServerName')"

docker run --rm -it -e ACCEPT_EULA=Y microsoft/mssql-server-windows-express sqlcmd -S $host,1433 -U sa -P $sa_password -Q "select name from sys.databases; select @@servername + '\' + @@servicename, SERVERPROPERTY('Edition'), SERVERPROPERTY('ServerName'),SERVERPROPERTY('EngineEdition'), serverproperty('resourceversion')"
from here:

to change the name after the server has been installed:
docker run --rm -it -e ACCEPT_EULA=Y microsoft/mssql-server-windows-express sqlcmd -S $host,1433 -U sa -P $sa_password -Q "EXEC sp_dropserver 'CURRENTNAMEHERE'; EXEC sp_addserver 'NEWNAMEHERE', 'local'; select @@servername;"

restart the server. the name is stored in one of the core DBs, as long as it is persisted your change will stay

How to stop sending telemetry data from MSSQL for Linux

/opt/mssql/bin/mssql-conf set telemetry.customerfeedback false
sudo systemctl restart mssql-server

settings are stored in

Enable TCP/IP from command line

with powershell for SQL Server 2016. Change ComputerManagement14 to lower versions of the SQL Server. The number can be found is in the registry and under program files folder

Get-CimInstance -Namespace root/Microsoft/SqlServer/ComputerManagement10 -ClassName ServerNetworkProtocol -Filter "InstanceName = 'SQLEXPRESS' and ProtocolName = 'Tcp'" | Invoke-CimMethod -Name SetEnable
# Open the right ports in the firewall
New-NetFirewallRule -DisplayName 'MSSQL$SQLEXPRESS' -Direction Inbound -Action Allow -Protocol TCP -LocalPort 1433
# Modify TCP/IP properties to enable an IP address
$properties = Get-CimInstance -Namespace root/Microsoft/SqlServer/ComputerManagement10 -ClassName ServerNetworkProtocolProperty -Filter "InstanceName='SQLEXPRESS' and ProtocolName = 'Tcp' and IPAddressName='IPAll'"
$properties | ? { $_.PropertyName -eq 'TcpPort' } | Invoke-CimMethod -Name SetStringValue -Arguments @{ StrValue = '1433' }
$properties | ? { $_.PropertyName -eq 'TcpPortDynamic' } | Invoke-CimMethod -Name SetStringValue -Arguments @{ StrValue = '' }
# Restart SQL Server
Restart-Service 'MSSQL$SQLEXPRESS'