Which is the best way to create a connection string for SQL Server?

Should I be using a trusted connection string (windows authentication) or an untrusted connection string (sql server authentication) and why?

My concern is to make my connection string more secure, so it does not get compromised by an attack.

I have read on many forums that Windows Authentication is more secure, and if we use SQL Server Authentication then the user id and password could be sniffed over the network.


Windows Authentication is going to be the most secure means, as opposed to SQL Server Authentication. The reason behind this is because with Windows Authentication, the OS handles the auth as opposed to SQL Server handling it with its respective method.

When you use Windows Auth, SQL Server just uses the authentication token that is stored when you log into Windows (the OS). This token-based security is more secure than SQL Server's native username/password security.

In other words if you can, choose Windows Authentication. There are times though when you cannot get around SQL Server authentication (legacy application, third-party vendor, etc.).

| improve this answer | |
  • can you please explain, what is this token based security in windows based authentication? – ravi Sep 22 '12 at 6:24

In my opinion, when it comes how secure the connection is, Windows authentication might works better, however you will be constraint and dependent on that along the way. For example if for some reasons there was a problem in windows users, the issue will flow to SQL accessibility as well. Usually the network and infrastructure person is different from SQL development team, so the DBA would be dependent on them tightly for applying changed on who can login or not.

| improve this answer | |
  • 1
    While that is a viable consideration for maintenance/troubleshooting, the inconvenience isn't justification to minimize security. – Thomas Stringer Sep 4 '12 at 3:37

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.