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:

Authentication SQLCMD

-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:

User andP PAssword SQL CMD

-U is the user login
-P is the password


3.  The QUIT control command causes sqlcmd to exit:

Quit SQL CMD

For more information see: https://learn.microsoft.com/en-us/sql/tools/sqlcmd/sqlcmd-use-utility?view=sql-server-ver16

Schneider Electric USA

Explore more
Range:
Users group

Discuss this topic with experts

Visit our community and get advice from experts and peers on this topic and more
Explore more
Range:
  • Products Documentation
  • Software Downloads
  • Product Selector
  • Product Substitution and Replacement
  • Help and Contact Center
  • Where to buy
  • Get a Quote
  • Find our Offices
  • Schneider Electric Community
  • Careers
  • Company Profile
  • Report a misconduct
  • Accessibility
  • Newsroom
  • Investors
  • EcoStruxure
  • Job Search
  • Blog
  • Tech Support: 877-342-5173
  • Privacy Policy
  • Cookie Notice
  • Terms of use
  • Change your cookie settings