SQL Server Command Line Tool - sqlcmd
sqlcmd.exe is a Microsoft SQL Server command-line tool that lets you connect to a SQL Server instance, run Transact-SQL statements, execute scripts, and automate routine tasks from a console or script. It's widely used by DBAs and developers for fast, GUI-free administration and automation.
sqlcmd.exe communicates with SQL Server using the Tabular Data Stream protocol. It accepts options like -S for server, -U/-P for login, -Q for a query, -i for input files, and -o for output, with -b to stop on errors and -m to control messages.
Reasons it's running:
sqlcmd.exe is Microsoft SQL Server's command-line tool used to execute T-SQL statements and scripts against a SQL Server instance, enabling automation and scripting without a GUI.
No, sqlcmd.exe is a legitimate Microsoft tool included with SQL Server Client Tools. Verify the digital signature and install source to ensure authenticity.
Use options like -S server, -i input_file.sql, -o output.txt, and optionally -U/-P for authentication. Example: sqlcmd.exe -S myserver -i script.sql -o results.txt.
Common locations include C:\Program Files\Microsoft SQL Server\Tools\Binn\sqlcmd.exe or C:\Program Files\Microsoft SQL Server\Client Tools\Tools\Binn\sqlcmd.exe, depending on the SQL Server version and tools chosen during install.
Ensure the Tools\Binn directory is in your PATH or call sqlcmd.exe by its full path. If not installed, install the SQL Server Command Line Utilities.
Yes. You can call sqlcmd.exe from PowerShell just like from CMD, and you can pipe or capture its output for further processing.
SQL Server Database Engine service that hosts and manages databases.
Legacy command-line tool for SQL Server that predates sqlcmd.exe (mostly deprecated).
Bulk Copy Program used for fast data export/import between SQL Server and data files.
Windows PowerShell host often used to invoke sqlcmd.exe in scripts and automation workflows.