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
Accounting Methods: Definition, Types, and Example
What are real-time payments? 7 useful FAQs for treasury & AP
Where To Go After Howling Pit Code Vein
Artem The Gambler
Craigslist Monterrey Ca
What Are Romance Scams and How to Avoid Them
Hotels Near 500 W Sunshine St Springfield Mo 65807
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Crusader Kings 3 Workshop
Edible Arrangements Keller
Seafood Bucket Cajun Style Seafood Restaurant in South Salt Lake - Restaurant menu and reviews
Charmeck Arrest Inquiry
Craigslist Deming
Accuradio Unblocked
Cbs Trade Value Chart Fantasy Football
Enterprise Car Sales Jacksonville Used Cars
Pricelinerewardsvisa Com Activate
2 Corinthians 6 Nlt
Elemental Showtimes Near Cinemark Flint West 14
Classic | Cyclone RakeAmerica's #1 Lawn and Leaf Vacuum
Zalog Forum
Espn Horse Racing Results
Bella Bodhi [Model] - Bio, Height, Body Stats, Family, Career and Net Worth 
Used Safari Condo Alto R1723 For Sale
John Chiv Words Worth
Holiday Gift Bearer In Egypt
Craigslist Roseburg Oregon Free Stuff
Wku Lpn To Rn
Cfv Mychart
San Jac Email Log In
Airg Com Chat
Publix Coral Way And 147
Devotion Showtimes Near The Grand 16 - Pier Park
Song That Goes Yeah Yeah Yeah Yeah Sounds Like Mgmt
Wbli Playlist
#scandalous stars | astrognossienne
Reli Stocktwits
CARLY Thank You Notes
Hisense Ht5021Kp Manual
Cranston Sewer Tax
2700 Yen To Usd
Live Delta Flight Status - FlightAware
5A Division 1 Playoff Bracket
Devotion Showtimes Near Showplace Icon At Valley Fair
Msatlantathickdream
R Detroit Lions
Campaign Blacksmith Bench
North Park Produce Poway Weekly Ad
Cataz.net Android Movies Apk
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.