{}

Our Brands

Impact-Company-Logo-English Black-01-177x54

Schneider Electric USA Website

Welcome to our website.
How can we help you today?
SQLCMD - Running SQL Queries from a Command Prompt

Article available in these languages: Czech

Issue
Running SQL statements to query data.

Product Line
Microsoft SQL Server

Environment
Command Prompt (DOS Window)

Cause
In some cases there could be no access to SQL Server Management Studio.

Resolution
*Warning: Irreparable database damage can occur. This procedure should only be performed by users familiar with SQL Server and proficient in writing SQL queries . Databases should be backed up prior to running any SQL statements.*

The sqlcmd utility lets users enter Transact-SQL statements, system procedures, and script files at the command prompt.

SYNTAX
sqlcmd <command-line option>

Syntax and command line options can be found at sqlcmd utility website.

1.  An example of how to connect to a SQL Server instance and run a query against a database:



-S parameter should be followed by the instance name
-E uses a trusted connection
GO signals the execution of the SQL statement.

2.  This example specifies the user and password when a trusted connection cannot be made:



-U is the user login
-P is the password


3.  The QUIT control command causes sqlcmd to exit:



Schneider Electric USA

Explore more
Range:
Articles that might be helpful Users group

Discuss this topic with experts

Visit our Community for first-hand insights from experts and peers on this topic and more.
Explore more
Range: