Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Execute SQL script file on MS-DOS prompt

4 réponses
Avatar
Carlo Villagacia
Dear Sir.
I need to execute an entire file which contains SQL script, and it has to be
executed throught the MS-DOS prompt.
1.- Do I need to use some command like "sqlserv or osql" or another one,
which one and how?
2.- Colud I use it with any version of SQL(I mean 97 an 2000)?
I thankfuly preciate if someone could help me

4 réponses

Avatar
Sérgio Monteiro
Carlo,

I supose u are Brazilian, so I'll write in portuguese. If I'm wrong, please
let me know.

1) Sim vc pode usar o comando isql ou osql. Dê uma olhada no Books Online
sobre estes comandos. Basicamente algo assim:

osql(isql) -SServer -E -i Script.sql -o logfile

2) Yes.
--
Sérgio Monteiro - Brasil
www.sqlpass.org
"Carlo Villagacia" escreveu na mensagem
news:%
Dear Sir.
I need to execute an entire file which contains SQL script, and it has to


be
executed throught the MS-DOS prompt.
1.- Do I need to use some command like "sqlserv or osql" or another one,
which one and how?
2.- Colud I use it with any version of SQL(I mean 97 an 2000)?
I thankfuly preciate if someone could help me




Avatar
Mohamed Sharaf
And here's another reply in English

osql utility is a SQL Server client that relay on ODBC library and it a
successor to the isql utility which relay on the DB-library and for more
information you can check.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/acdata/ac_8_mta_01_5cmk.asp



--
Mohamed Sharaf
Microsoft GTSC Developer support for Middle East




"Carlo Villagacia" wrote in message
news:%
Dear Sir.
I need to execute an entire file which contains SQL script, and it has to


be
executed throught the MS-DOS prompt.
1.- Do I need to use some command like "sqlserv or osql" or another one,
which one and how?
2.- Colud I use it with any version of SQL(I mean 97 an 2000)?
I thankfuly preciate if someone could help me




Avatar
Shahid Gaglani [MSFT]
Hi guys,

Just to make it a little more easy on everyone in the group, I am copying an
excerpt from the SQL Server Books Online that should answer all your
queries. For more in-depth information about this, feel free to open the SQL
Server Books Online and read the topic OSQL utility:

[QUOTE]
Using the osql Utility
The osql utility is a Microsoft® Win32® command prompt utility for ad hoc,
interactive execution of Transact-SQL statements and scripts. To use osql,
users must understand Transact-SQL.

The osql utility is typically used in these ways:

a.. Users interactively enter Transact-SQL statements in a manner similar
to working on the command prompt. The results are displayed in the command
prompt window.


b.. Users submit an osql job either specifying a single Transact-SQL
statement to execute or pointing the utility to a text file that contains
Transact-SQL statements to execute. The output is usually directed to a text
file, but it also can be displayed in the command prompt window.
The osql utility uses the ODBC database application programming interface
(API). It is a replacement for the isql command prompt utility based on the
DB-Library API. Both utilities are provided with Microsoft SQL ServerT 2000.
The DB-Library API remains at a SQL Server 6.5 level; therefore,
applications that depend on DB-Library, such as isql, do not support some
SQL Server 2000 features. For example, isql cannot access columns defined
with the ntext data type and truncates any char, varchar, nchar, or nvarchar
columns longer than 255 bytes. It also cannot retrieve results as XML
documents. Except for these limitations in isql, both osql and isql support
the same features

[UNQUOTE]

Hope this helps,

Shahid Gaglani [MSFT]


Microsoft Disclaimer:
This posting is provided AS IS with no warranties, and confers no rights. OR
if you wish to include a script
sample in your post please add Use of included script samples are subject to
the terms specified at http://www.microsoft.com/info/cpyright.htm


"Mohamed Sharaf" wrote in message
news:eXZL$
And here's another reply in English

osql utility is a SQL Server client that relay on ODBC library and it


a
successor to the isql utility which relay on the DB-library and for more
information you can check.




http://msdn.microsoft.com/library/default.asp?url=/library/en-us/acdata/ac_8_mta_01_5cmk.asp



--
Mohamed Sharaf
Microsoft GTSC Developer support for Middle East




"Carlo Villagacia" wrote in message
news:%
> Dear Sir.
> I need to execute an entire file which contains SQL script, and it has


to
be
> executed throught the MS-DOS prompt.
> 1.- Do I need to use some command like "sqlserv or osql" or another one,
> which one and how?
> 2.- Colud I use it with any version of SQL(I mean 97 an 2000)?
> I thankfuly preciate if someone could help me
>
>




Avatar
»Æɽ¹âÃ÷¶¥
hi guys

you can use OSQL or ISQL utility to execute the T-SQL script,first you must
save the T-SQL to a text file,then you create a batch file like
"exec_sql.bat" contains:
--%1 and %2....is the input parameters
@isql -S %2 -U %4 -P %5 -d %3 -n -i %1ALTERtb_delta.sql -o
%1ALTERtb_delta.out

leimin


"Carlo Villagacia" wrote in message
news:%
Dear Sir.
I need to execute an entire file which contains SQL script, and it has to


be
executed throught the MS-DOS prompt.
1.- Do I need to use some command like "sqlserv or osql" or another one,
which one and how?
2.- Colud I use it with any version of SQL(I mean 97 an 2000)?
I thankfuly preciate if someone could help me