My windows user was not allowed to run netstat -abn
as suggested in geographika's answer, but I could work around it:
By using tasklist | find /i "Ssms.exe"
, I got the following result:
Ssms.exe 14144 RDP-Tcp#15 3 233.384 K
14144
in the example above is the PID. Next I entered netstat -oan | find /i "14144"
This will return (probably more than one line):
TCP 192.168.100.102:60348 192.168.100.102:55600 HERGESTELLT 14144
So the Port to connect to would be 55600.
This answer gave me the hint needed, but it didn't work as expected so I had to adapt it a little.
(EDIT: Somehow forgot to put it all together.)
Now we can connect using sqlcmd the IP and the Port:
sqlcmd -S 192.168.100.102,55600 -U User -P pwd -d DatabaseName -Q "SELECT TOP 5 Id FROM dbo.MyTable;"