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)