🔗 Connect to your data and build better dashboards with Plotly and Claude. Reserve your spot.

Connect to your relational database with Plotly

Connect Microsoft SQL Server to Plotly Studio

TRY PLOTLY STUDIO
play-icon

Step-by-step Microsoft SQL Server data connection setup

Microsoft SQL Server is an enterprise-grade relational database management system. It offers robust security, high availability, and deep integration with the Microsoft ecosystem, widely used in corporate environments for mission-critical applications.

Connecting to Microsoft SQL Server requires your host address, port, database name, and login credentials. SQL Server environments often have specific authentication configurations, so confirming that SQL Server Authentication is enabled with your DBA before starting is worthwhile. Follow these steps to connect to your SQL Server data and visualize it with Plotly Studio:

Step 1: Confirm your SQL Server instance is running

MS SQL Server can be running locally (including via Docker), on a private corporate server, or as a managed cloud service through Azure SQL Database, AWS RDS for SQL Server, or Google Cloud SQL for SQL Server. Wherever it lives, confirm that your instance is up, remote connections are enabled, and TCP/IP is turned on in SQL Server Configuration Manager.

Step 2: Enable SQL Server Authentication

By default, some SQL Server instances are configured for Windows Authentication only. Plotly Studio connects using a username and password (SQL Server Authentication), so confirm this mode is enabled. In SQL Server Management Studio (SSMS), right-click your server, go to Properties > Security, and select SQL Server and Windows Authentication mode.

Step 3: Create a dedicated login (recommended)

Rather than connecting as sa, create a dedicated SQL login with only the permissions Plotly Studio needs:

CREATE LOGIN [plotly_user] WITH PASSWORD = '[YOUR_SECURE_PASSWORD]';
USE [YOUR_DATABASE];
CREATE USER [plotly_user] FOR LOGIN [plotly_user];
GRANT SELECT ON SCHEMA::dbo TO [plotly_user];

Step 4: Gather your connection details

Have these values ready before opening Plotly Studio. You'll find them in SSMS, your cloud provider's dashboard, or from the credentials used when the instance was provisioned.

Credentials needed

  • Host: IP address, hostname, or localhost (e.g., db.company.com or 127.0.0.1)
  • Port: typically 1433 (default SQL Server port)
  • Database: the name of the target database (e.g., testdb)
  • Username: your SQL Server login (e.g., sa or a dedicated service user)
  • Password: your SQL Server login password

Tip: contact us if you need help troubleshooting these steps.

LLM prompts for connecting to Microsoft SQL Server

Plotly Studio uses an AI agent to generate and execute the data connection code for you. The prompts below are ready to copy and paste directly into Plotly Studio's data connection chat. Use them to establish a connection, query your data, or do both in one shot. The global context rules are worth saving to your Plotly Studio global context to keep SQL Server connections consistent across projects.

Connection prompt

Connect to a Microsoft SQL Server database using the pyodbc library with the
ODBC Driver 17 for SQL Server. Build a connection string using the provided
server host, port, database name, username, and password with SQL Server
Authentication (UID/PWD). Verify the connection, then list all available
tables in the target database using a query against
INFORMATION_SCHEMA.TABLES.

Query prompt

Using the established MSSQL connection, retrieve all rows from the table
[YOUR_SCHEMA].[YOUR_TABLE_NAME] in the [YOUR_DATABASE_NAME] database.
Execute the query using a cursor, fetch the results with fetchall(), and
return them as a pandas DataFrame. Use standard T-SQL syntax only.

Example one-shot prompt

Connect to a Microsoft SQL Server database using pyodbc and ODBC Driver 17
for SQL Server with the following credentials:

Host/Server: [YOUR_HOST_OR_IP]
Port: [YOUR_PORT] (default: 1433)
Database: [YOUR_DATABASE_NAME]
Username: [YOUR_USERNAME]
Password: [YOUR_PASSWORD]

Build a connection string in this format:
DRIVER={ODBC Driver 17 for SQL Server};SERVER=[HOST],[PORT];DATABASE=[DATABASE];UID=[USERNAME];PWD=[PASSWORD]

Once connected, retrieve all rows from the table dbo.[YOUR_TABLE_NAME] and
return the result as a pandas DataFrame. Display a preview of the data.

Global context rules

- Always use pyodbc as the primary connection library for MSSQL.
- Always use ODBC Driver 17 for SQL Server in the driver string. Fall back
to ODBC Driver 18 if 17 is unavailable.
- Always build the connection string with explicit SERVER, DATABASE, UID,
and PWD parameters. Include the port as part of the SERVER value in the
format SERVER=host,port.
- Always use SQL Server Authentication (UID/PWD). Do not attempt OAuth or
Windows Integrated Authentication (Trusted_Connection=yes) unless explicitly
instructed.
- Always use T-SQL syntax. Do not use MySQL, PostgreSQL, or other SQL
dialects.
- Always return query results as a pandas DataFrame using pd.read_sql() or
cursor + fetchall().
- If the table schema is unknown, query INFORMATION_SCHEMA.COLUMNS for the
target table first to confirm column names and types before building the
main query.
- Default to TOP 10000 rows when querying large tables unless the user
explicitly requests a full pull.
- Always use schema-qualified table names (e.g., dbo.tablename) to avoid
ambiguity.
- Do not log or expose raw password values in any output or error messages.

Troubleshooting and tips

  • Permissions: The connecting user needs at minimum SELECT permission on the target schema. The VIEW DEFINITION permission is also helpful so Plotly Studio can enumerate tables and inspect schema. Avoid using sa in production — create a scoped login instead.
  • Default port: MS SQL Server's default port is 1433. Non-standard ports are common in enterprise environments — always confirm with your DBA before connecting.
  • Docker: If you're running SQL Server locally via Docker, your host will be localhost and the default port 1433. Make sure the container's port is mapped and exposed before attempting to connect.
  • ODBC Driver requirement: pyodbc requires the Microsoft ODBC Driver for SQL Server to be installed on the server where Plotly Studio is running. Driver 17 is the most broadly compatible version; Driver 18 adds TLS 1.3 support. If you see a driver-not-found error, this is the likely cause — check with your admin.
  • Named instances: If your SQL Server is running as a named instance (e.g., SERVERNAME\INSTANCENAME), use the backslash notation in the Server field rather than just an IP address.
  • Authentication methods: Plotly Studio works best with username and password (SQL Server Authentication). It does not currently support OAuth. Other authentication methods such as Windows Integrated Authentication, Active Directory, Kerberos, or certificate-based auth may be available depending on your organization's setup, but will require working with your system administrator to determine how to pass the appropriate credentials or connection string.

Connect to Microsoft SQL Server in minutes with Plotly Studio

Download today for free and get started with Plotly Studio.

GET STARTED
Bluesky icon
X icon
Instagram icon
Youtube icon
Medium icon
Facebook icon

Product

© 2026
Plotly. All rights reserved.
Cookie Preferences