Which command-line tool can you use to query Azure SQL databases?
Click on the arrows to vote for the correct answer
A. B. C. D.A
The sqlcmd utility lets you enter Transact-SQL statements, system procedures, and script files at the command prompt.
Incorrect Answers:
B: The bulk copy program utility (bcp) bulk copies data between an instance of Microsoft SQL Server and a data file in a user-specified format.
D: The Azure CLI is the defacto tool for cross-platform and command-line tools for building and managing Azure resources.
https://docs.microsoft.com/en-us/sql/tools/overview-sql-tools?view=sql-server-ver15The command-line tool that can be used to query Azure SQL databases is sqlcmd.
sqlcmd is a command-line tool that is used to execute Transact-SQL statements and scripts on SQL Server instances, including Azure SQL databases. It can be used to connect to a database and execute queries, stored procedures, and other commands.
To use sqlcmd, you need to have it installed on your local machine or the machine where you plan to run the queries. You also need to have the necessary permissions to access the Azure SQL database.
Here's an example of how to use sqlcmd to connect to an Azure SQL database:
csssqlcmd -S myserver.database.windows.net -U myusername -P mypassword -d mydatabase
In this example, myserver.database.windows.net is the fully qualified server name for the Azure SQL database, myusername and mypassword are the credentials for accessing the database, and mydatabase is the name of the database you want to query.
Once you are connected, you can execute queries using Transact-SQL syntax. For example:
sqlSELECT * FROM mytable
This query will retrieve all rows from the mytable table in the connected Azure SQL database.
In summary, sqlcmd is the command-line tool used to query Azure SQL databases. It allows you to execute Transact-SQL statements and scripts on SQL Server instances, including Azure SQL databases, and provides a way to connect to the database and execute queries, stored procedures, and other commands.