Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to use osql

Shulou Source: shulou.com Published: 2022-06-01 01:26:22 09月11日 Update

This article mainly shows you "how to use osql", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to use osql" this article.

When operating in the multi-person login database interface, it is easy to have problems when accessing and processing data, and sometimes even crash. The OSQL statement is used to operate later.

The osql tool is a Microsoft Windows 32 command prompt tool that you can use to run Transact-SQL statements and script files, and then append the results to a file, which is efficient and convenient to run.

Here is an example of my work:

Osql.exe-S DB01\ BOOK-E-I D:\ tpp\ sql.txt save this sentence as a bat file.

In sql.txt is my sql statement. The example is as follows:

SELECT COUNT (zongji1_ID) as jsj_tushu

FROM bookstore

Go

SELECT COUNT (zongji2_ID) as sheke_tushu

FROM bookstore

Go

SELECT COUNT (zongji3_ID) AS wenxue_tushu

FROM bookstore

Go

At the cmd prompt, execute osql.bat > > shuju_20100729.log.

A brief description of the parameters:

Osql's-s

Specifies the default instance of SQL Server to connect to.

Osql's-e

Specify to connect to the local default instance using Windows authentication

Osql-I

Specifies the SQL statement file to load. When you don't want to type too many SQL statements, you can write it in a file and use this parameter as a batch to execute.

Also notice that the default installation path for osql is under C:\ Program Files\ Microsoft SQL Server\ 90\ Tools\ binn.

The above is all the content of this article "how to use osql". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Files statements content articles parameters examples tools prompts data learning help prompts runs examples commands multiple people efficiency database easy to understand more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB NVidia Shulou Information MySQL vpn