2

I'm using SQL 2005, and was helping someone debug a connection issue today. I thought that I could view my current connection string from inside SQL Management Studio, but can't seem to figure out how to make it happen.

Is this possible? Google hunting has been fruitless.

Thanks!

1

You can't view your current SQL Management Studio connection string from within SQL Management Studio.

You could whip up your own connection string pretty quickly using the same details as when connecting to your SQL instance. Here's a resource with examples which might be helpful: http://www.connectionstrings.com/sql-server-2005

Hopefully I understood your question correctly...?

| improve this answer | |
  • If you know for sure that I can't, then that's my answer. Finding a connection string isn't my issue - I just thought they'd have made it easy to see my current connection string in SSMS, like you can in Visual Studio. Odd. – Ducain Oct 5 '10 at 1:12
  • 1
    This sucks. Why not? – Colonel Panic Mar 15 '12 at 14:08
10

You can. From Stack Exchange:

select
    'data source=' + @@servername +
    ';initial catalog=' + db_name() +
    case type_desc
        when 'WINDOWS_LOGIN' 
            then ';trusted_connection=true'
        else
            ';user id=' + suser_name()
    end
from sys.server_principals
where name = suser_name()
| improve this answer | |
  • Data Source / Server in Connection String != @@servername. Local host entries, SQL Client Aliases, and DNS mappings will all report something other than the what is in the Connection String. (Which is good, because none of those should change the nominative server [AD] + instance name, and also means that it can't be used to provide a guaranteed valid CS - ie, AD name might not be exposed - much less the actual CS..) – user2864740 Aug 11 '18 at 1:14
0

this may be too late, but there seems to be a better answer for this question.

I was searching for the same thing; how do I view the connection string to a particular SQL Server database. I read you cannot do it within SQL Server Management Studio, but you can retrieve the connection string Visual Studio uses, as suggested by another user.

In Visual Studio, go to Server Explorer and choose to create a new connection by right clicking on Data Connections and browsing to the SQL Server to which you wish to connect. I am connecting to both SQL Server and MySQL so I would note this down for myself and others who might be in the same boat, so to speak.

When choosing a new Data Source, specify Microsoft SQL Server for your SQL connection, but MySQL needs a connector. You will need to have a MySQL/Oracle account to download the connector for MySQL.

http://dev.mysql.com/downloads/connector/net

Once this is installed, you will have an option of Oracle database when you are creating a new data connection for MysQL. You can now configure and connect to your data source and view the connection string for each data source. To do so, right click on the new Data Connection and select Properties. In the Connection String, you can copy and paste this for your Visual Studio connection string.

Again, since this came back in my search results, I am adding this note for myself in the future and possible others may find this useful.

Keenan

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.