0

We have a SQL Server but access is limited so we can't access the server directly. The only available access is to use another server running on CentOS Linux where I can SSH to it and then from this intermediate server to further connect to this SQL Server.

I am looking a simple way to list databases and schema on the SQL Server.

What would be the command to do the above from this Linux server, assuming one has the IP address and credentials of the SQL Server.

Dale K
  • 25,246
  • 15
  • 42
  • 71
busheriff
  • 155
  • 1
  • 11
  • Does the administrator allow you to use SSH Tunnels? Create an SSH Tunnel from a local port, say 127.0.0.1:1433, to the remote SQL Server over the SSH connection and then you can connect your favourite SQL tools to 127.0.0.1:1433 while the SSH connection is running. – AlwaysLearning May 05 '21 at 22:02
  • SSH tunnels are not allowed. Was provided IP address, tcp port and credential – busheriff May 05 '21 at 22:09
  • There is a command line client that can be installed on linux. It is currently in preview but might work for you if it's already installed or you can install it on the linux box. You should be able to use it to connect to and query the remote SQL Server instance. [Installation](https://learn.microsoft.com/en-us/sql/tools/mssql-cli?view=sql-server-ver15) [Usage Guide](https://github.com/dbcli/mssql-cli/blob/master/doc/usage_guide.md) – squillman May 05 '21 at 22:14
  • What does you mean by "schema" as well. A schema is a specific object type in SQL Server, the default for most people being `dbo`. I doubt that is what you mean though. – Thom A May 05 '21 at 22:14
  • In truth though, it sounds like you should be speaking to someone who does have access to the instance and asking them to provide you with the information you need. – Thom A May 05 '21 at 22:15
  • @squillman is it a separate package to install mssql-cli? I tried to install it using yum install on the linux server that I have access but it said no package mssql-cli available. – busheriff May 05 '21 at 22:37
  • @Larnu: What I am trying to do is to list all tables in database and then once I know the table I want, I'd like to list the schema or simply column names of a desired table – busheriff May 05 '21 at 22:37
  • Try using the standard sqlcmd program in interactive mode. But seriously - talk to someone and get the access you need. Alternatively get a copy of the schema that you can use to create an empty database in your own instance. Or perhaps they can give you a database backup with "sample" data that you can use locally. – SMor May 05 '21 at 22:43

0 Answers0