snippetsqlModerate
How to check connection string in SSMS2012?
Viewed 0 times
howssms2012checkstringconnection
Problem
I'm connected to database. I use db by Management Studio 2012 Express. Can I check connection string by click something in Management Studio?
Solution
Within SSMS, I'm not sure there's an easy way to do that. But a simple query will return you the information (without the password of a connection string, obviously):
Note,
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()Note,
db_name() will return the current database name if there is no parameter specified, so that is dependent on your current scope.Code Snippets
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()Context
StackExchange Database Administrators Q#20528, answer score: 11
Revisions (0)
No revisions yet.