SQL Server command line tool osql usage

Source: Internet
Author: User

C: \> osql /?
Usage: osql [-u Login ID] [-P Password]
[-S server] [-H hostname] [-e trusted connection]
[-D use database name] [-l login timeout] [-T query timeout]
[-H headers] [-s colseparator] [-W columnwidth]
[-A packetsize] [-e echo input] [-I enable quoted identifiers]
[-L list servers] [-C cmdend] [-d odbc dsn name]
[-Q "Explain line query"] [-Q "Explain line query" and exit]
[-N remove numbering] [-M errorlevel]
[-R msgs to stderr] [-V severitylevel]
[-I inputfile] [-O outputfile]
[-P print statistics] [-B on error batch abort]
[-O use old iSQL behavior disables the following]
<EOF> batch processing in progress
Console width auto-Adjusted
Wide message
The default error level is-1 to 1.
[-? Show syntax Summary]

Windows Integrated Identity login >>>
C: \> osql-e
1>
Execute system stored procedures after login
1> sp_password null, "newpass", "sa"
2> go
The password has been changed.
1> exit

Let's take a look at SA hybrid login >>>
C: \> osql-slocalhost-USA-pnewpass
1>
1> A prompt is displayed, indicating that the logon is successful!

Let's take a look at the osql command line to query c: \> osql-slocalhost-USA-pnewpass
1> Use qz
2> select count (*) from crjsj where kh = 0
3> go

-----------
0

(Line 1 is affected)
1>
Query System Table
1> select name from sysobjects where xtype = 'U'
2> go
Name


-------------------------------------------------------------------------------

-------------------------------------------------
SJD


Sjdz


Xgjsz


Xtcs


PB


Xtsz


Qjcc


Rszl


Rz


T_open_event


T_open_event_history


Xgsj


T_opendoorrecord_history


Mjjcs2


T_opendoorrecord


Mjjz2


Mjkzqcs2


Dtproperties


Qjcc1.


Sjlxsm


Kqsj2


Bell


BM


Card


Department


Crjsj


Ugly


Gzsj_history


Crjsj_history


JR


Gzsj


Kqjsz


Gzsj_ssjksj


Info


Lever


Kqbc


Kqsj


Kqsj_tp


Lscrjsj


Mjjcs


Msgrz


Parameter


Picture


Mjjz


Qjlb


Mjkzqcs

 

(46 rows affected)
1> exit

C: \> the osql command line has many functions and is often used as an example.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.