[SQL Server] script execution is called in iSQL, osql, and sqlcmd.

Source: Internet
Author: User
Execute scripts in iSQL, osql, and sqlcmd.

According to the previous http://blog.csdn.net/xys_777/archive/2010/06/18/5679174.aspx
Continue to compile iSQL, osql, and sqlcmd usage

1. Create the file test. SQL on drive C, open the editing, and write the following code:Code:

Declare @ TB table
(
Id int identity,
Code varchar (30)
)

Insert @ TB
Select 'a = 123, B = 32, c = 444, D = 1r13 'Union all
Select 'a = 123, B = 32, c = 44, D = 1r13'
-- Query
Select
Substring (Code, charindex ('C = ', code) + 2, charindex (', D = ', Code)-charindex ('C =', Code)-2)
From @ TB

 

-- You can write any code you want to execute.

2. Create the file test. bat on drive C, open the edit, and write the call statement, saving you the need to call it each time you open the CMD window.

"C:/program files/Microsoft SQL Server/90/tools/binn/osql. EXE"-e-ic:/test. SQL-OC:/test.txt-n

 

3. Double-click test.bat, and you can access test.txt.

(2 rows affected)

------------------------------
444
44

(2 rows affected)

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.