Connect to Synapse SQL with sqlcmd - Azure Synapse Analytics (2024)

  • Article

You can use the sqlcmd command-line utility to connect to and query serverless SQL pool and dedicated SQL pool within Synapse SQL.

1. Connect

To get started with sqlcmd, open the command prompt and enter sqlcmd followed by the connection string for your Synapse SQL database. The connection string requires the following parameters:

  • Server (-S): Server in the form <Server Name>-ondemand.sql.azuresynapse.net(Serverless SQL pool) or <Server Name>.sql.azuresynapse.net(Dedicated SQL pool)
  • Database (-d): Database name
  • Enable Quoted Identifiers (-I): Quoted identifiers must be enabled to connect to a Synapse SQL instance

To use SQL Server Authentication, you need to add the username and password parameters:

  • User (-U): Server user in the form <User>
  • Password (-P): Password associated with the user

Your connection string might look like the following example:

Serverless SQL pool

C:\>sqlcmd -S partyeunrt-ondemand.sql.azuresynapse.net -d demo -U Enter_Your_Username_Here -P Enter_Your_Password_Here -I

Dedicated SQL pool

C:\>sqlcmd -S MySqlDw.sql.azuresynapse.net -d Adventure_Works -U myuser -P myP@ssword -I

To use Microsoft Entra integrated authentication, you need to add the Microsoft Entra parameters:

  • Microsoft Entra authentication (-G): use Microsoft Entra ID for authentication

Your connection string might look like on of the following examples:

Serverless SQL pool

C:\>sqlcmd -S partyeunrt-ondemand.sql.azuresynapse.net -d demo -G -I

Dedicated SQL pool

C:\>sqlcmd -S MySqlDw.sql.azuresynapse.net -d Adventure_Works -G -I

Note

You need to enable Microsoft Entra authentication to authenticate using Active Directory.

2. Query

Use dedicated SQL pool

After connection, you can issue any supported Transact-SQL (T-SQL) statements against the instance. In this example, queries are submitted in interactive mode:

C:\>sqlcmd -S MySqlDw.sql.azuresynapse.net -d Adventure_Works -U myuser -P myP@ssword -I1> SELECT name FROM sys.tables;2> GO3> QUIT

For dedicated SQL pool, the following examples show you how to run queries in batch mode using the -Q option or piping your SQL to sqlcmd:

sqlcmd -S MySqlDw.sql.azuresynapse.net -d Adventure_Works -U myuser -P myP@ssword -I -Q "SELECT name FROM sys.tables;"
"SELECT name FROM sys.tables;" | sqlcmd -S MySqlDw.sql.azuresynapse.net -d Adventure_Works -U myuser -P myP@ssword -I > .\tables.out

Use serverless SQL pool

After connecting, you can issue any supported Transact-SQL (T-SQL) statements against the instance. In the following example, queries are submitted in interactive mode:

C:\>sqlcmd -S partyeunrt-ondemand.sql.azuresynapse.net -d demo -U Enter_Your_Username_Here -P Enter_Your_Password_Here -I1> SELECT COUNT(*) FROM OPENROWSET(BULK 'https://azureopendatastorage.blob.core.windows.net/censusdatacontainer/release/us_population_county/year=20*/*.parquet', FORMAT='PARQUET')2> GO3> QUIT

For serverless SQL pool, the examples that follow show you how to run queries in batch mode using the -Q option or piping your SQL to sqlcmd:

sqlcmd -S partyeunrt-ondemand.sql.azuresynapse.net -d demo -U Enter_Your_Username_Here -P 'Enter_Your_Password_Here' -I -Q "SELECT COUNT(*) FROM OPENROWSET(BULK 'https://azureopendatastorage.blob.core.windows.net/censusdatacontainer/release/us_population_county/year=20*/*.parquet', FORMAT='PARQUET')"
"SELECT COUNT(*) FROM OPENROWSET(BULK 'https://azureopendatastorage.blob.core.windows.net/censusdatacontainer/release/us_population_county/year=20*/*.parquet', FORMAT='PARQUET')" | sqlcmd -S partyeunrt-ondemand.sql.azuresynapse.net -d demo -U Enter_Your_Username_Here -P 'Enter_Your_Password_Here' -I > ./tables.out

Next steps

For more information about sqlcmd options, see the sqlcmd documentation.

Connect to Synapse SQL with sqlcmd - Azure Synapse Analytics (2024)
Top Articles
Save Money When You're Broke ~ 10 Easy Ways | Not Quite an Adult
🔥 Sector Indices | CFD Trading
Pangphip Application
PRISMA Technik 7-10 Baden-Württemberg
San Diego Terminal 2 Parking Promo Code
Lenscrafters Westchester Mall
Craigslist Phoenix Cars By Owner Only
W303 Tarkov
R/Altfeet
Hartford Healthcare Employee Tools
The fabulous trio of the Miller sisters
Ts Lillydoll
Gia_Divine
Closest Bj Near Me
Promiseb Discontinued
Culver's Flavor Of The Day Taylor Dr
Euro Style Scrub Caps
Pecos Valley Sunland Park Menu
Woodmont Place At Palmer Resident Portal
Morse Road Bmv Hours
Chime Ssi Payment 2023
Https E22 Ultipro Com Login Aspx
Pulitzer And Tony Winning Play About A Mathematical Genius Crossword
manhattan cars & trucks - by owner - craigslist
Downloahub
How Do Netspend Cards Work?
417-990-0201
Rogold Extension
Mp4Mania.net1
Barrage Enhancement Lost Ark
Despacito Justin Bieber Lyrics
Kips Sunshine Kwik Lube
Cookie Clicker The Advanced Method
Top 25 E-Commerce Companies Using FedEx
This 85-year-old mom co-signed her daughter's student loan years ago. Now she fears the lender may take her house
Davis Fire Friday live updates: Community meeting set for 7 p.m. with Lombardo
Umiami Sorority Rankings
How to Get a Better Signal on Your iPhone or Android Smartphone
Emulating Web Browser in a Dedicated Intermediary Box
Nid Lcms
Www.craigslist.com Waco
2024-09-13 | Iveda Solutions, Inc. Announces Reverse Stock Split to be Effective September 17, 2024; Publicly Traded Warrant Adjustment | NDAQ:IVDA | Press Release
Babykeilani
Argus Leader Obits Today
Turok: Dinosaur Hunter
Grace Family Church Land O Lakes
Hampton Inn Corbin Ky Bed Bugs
David Turner Evangelist Net Worth
Syrie Funeral Home Obituary
Bellin Employee Portal
Texas 4A Baseball
Latest Posts
Article information

Author: Domingo Moore

Last Updated:

Views: 5942

Rating: 4.2 / 5 (53 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Domingo Moore

Birthday: 1997-05-20

Address: 6485 Kohler Route, Antonioton, VT 77375-0299

Phone: +3213869077934

Job: Sales Analyst

Hobby: Kayaking, Roller skating, Cabaret, Rugby, Homebrewing, Creative writing, amateur radio

Introduction: My name is Domingo Moore, I am a attractive, gorgeous, funny, jolly, spotless, nice, fantastic person who loves writing and wants to share my knowledge and understanding with you.