How to use VS Code's SQLTools extension to log in to a SQL Server database with domain credentials

161 Views Asked by At

I can successfully use SQL Server Management Studio and Python (via SQLAlchemy) to access a database. I would like to use VSCode's SQLTools extension to do the same. Below are my settings

These methods work

SQL Server Management Studio:

Parameter Value
Server Type Database Engine
Server name Server1.subdomain.domain.com
User name userdomain\userid
Password

Python with SQLAlchemy

Parameter Value
Connection string mssql+pymssql://userdomain\userid:[email protected]/database

These methods do not work

VSCode using connection string:

Parameter Value
Connection string mssql+pymssql://userdomain\userid:[email protected]

This throws an error

The "config.server" property is required and must be of type string

VS Code using server and port:

Parameter Value
Connection name Connection1
Connect using Server and Port
Server Address Server1.subdomain.domain.com
Username userdomain\userid
Password Ask on connect

This throws an error

Login failed for user 'userdomain\userid'

I've also tried using userid for "username", without userdomain.

1

There are 1 best solutions below

9
nbk On

The connection sting is a normal one, like the ones for ADO.NET

server=mydbserver;database=mydatabase;Integrated Security=false;User ID=domain\username;Password=your_pass

you need to remove the integrated services from the string, which are for windows authetification

server=mydbserver;database=mydatabase;User ID=username;Password=your_pass