Is there a way to have Excel connect to Sql Server using the current user's network windows authentication (trusted connection/integrated security)? I don't want to rely on a sql login or have a uid/password in my code.
Asked
Active
Viewed 9.0k times
4 Answers
16
I have this connectionstring in an Excel 2003 VBA project...
"Provider=SQLOLEDB;Data Source=[You DB Name];Trusted_connection=yes;"
And it works for me! (I'm using ADODB)

El Ronnoco
- 11,753
- 5
- 38
- 65
10
Driver={SQL Native Client};server=servernamehere;database=dbnamehere;Trusted_Connection=yes;
http://www.sqlstrings.com/SQL-Server-connection-strings.htm
http://www.connectionstrings.com/sql-server
Try this one:
Provider=sqloledb;Data Source=myServerName;Initial Catalog=myDatabaseName;Integrated Security=SSPI

Cade Roux
- 88,164
- 40
- 182
- 265
-
2What Data Access component are you using? – Cade Roux Oct 15 '09 at 20:34
-
2"doesn't work" is the least helpful comment you can make. Why doesn't it work? do you get an error? A message? Nothing? – Nick.Mc Feb 07 '16 at 11:32
3
See: http://www.connectionstrings.com/
Especially http://www.connectionstrings.com/sql-server-2005, for example:
Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;
or any other suitable connection string you find there.

Tomalak
- 332,285
- 67
- 532
- 628
1
Working sample for VBA Excel 2010
Provider=SQLOLEDB;Data Source=ServerIPOrName;Initial Catalog=DatabaseName;Trusted_connection=yes;

Stefan Michev
- 4,795
- 3
- 35
- 30