Example 1: Specify the relative path of the sql file to be executed.
osql-S admin \ admin-U sa-P sa-d test db-I c:\ test . SQL
discontinue
Example 2: The file to be executed and the bat file are in the same directory, and the relative path is specified.
Set local directory =%~dp0
Osql -S (local)-u sa-p sa-d test-i% localdir% \ test1.sql.
Osql -S (local)-u sa-p sa-d test-i% localdir% \ test2.sql.
Osql -S (local)-u sa-p sa-d test-i% localdir% \ test3.sql.
discontinue
(2) Create sql scripts to be executed, namely, test.sql, test2.sql and test3.sql, and put them in the location specified by example 1 in step (1). In this case, it is the c:\ root directory. If you use Example 2, put the sql and bat files in the same directory.
(3) Double-click *. Bat file and check the running results.