Home All Groups Group Topic Archive Search About
Author
23 Nov 2005 1:45 PM
Marek
Is there a way to process multiple SQL scripts in a single transaction using
osql.exe ?
Ideally, I'd like to be able to start transaction, execute multiple sql
scripts and commit transaction when all of them succeeded or rollback when
there was a failure.
I appreciate your help.

Author
23 Nov 2005 2:18 PM
Jens
I would copy and paste them together.

-jens Süßmeyer.
Author
23 Nov 2005 3:14 PM
Ole Kristian Bangås
"Marek" <nospam@nowhere.com> wrote in
news:#BmMdSD8FHA.2676@TK2MSFTNGP15.phx.gbl:

> Is there a way to process multiple SQL scripts in a single transaction
> using osql.exe ?
> Ideally, I'd like to be able to start transaction, execute multiple
> sql scripts and commit transaction when all of them succeeded or
> rollback when there was a failure.
> I appreciate your help.

As far as I know this is not possible in osql, but if you try sqlcmd from
SQL Server 2005, I do believe that you can. However, I have not tried this.
SqlCmd is also available in SQL Server 2005 Express, which is free.

--
Ole Kristian Bangås
MCT, MCDBA, MCDST, MCSE:Security, MCSE:Messaging
Author
23 Nov 2005 3:23 PM
Ole Kristian Bangås
Show quote
"Ole Kristian Bangås" <olekristian.ban***@masterminds.no> wrote in
news:Xns9717A547BD7D7olekristianbangaas@207.46.248.16:

> "Marek" <nospam@nowhere.com> wrote in
> news:#BmMdSD8FHA.2676@TK2MSFTNGP15.phx.gbl:
>
>> Is there a way to process multiple SQL scripts in a single
>> transaction using osql.exe ?
>> Ideally, I'd like to be able to start transaction, execute multiple
>> sql scripts and commit transaction when all of them succeeded or
>> rollback when there was a failure.
>> I appreciate your help.
>
> As far as I know this is not possible in osql, but if you try sqlcmd
> from SQL Server 2005, I do believe that you can. However, I have not
> tried this. SqlCmd is also available in SQL Server 2005 Express, which
> is free.

And as Tibor so kindly answered in another group: You can download SqlCmd
here:
http://www.microsoft.com/downloads/details.aspx?familyid=D09C1D60-A13C-
4479-9B91-9E8B9D835CDC&displaylang=en

--
Ole Kristian Bangås
MCT, MCDBA, MCDST, MCSE:Security, MCSE:Messaging
Author
23 Nov 2005 3:44 PM
Tibor Karaszi
> As far as I know this is not possible in osql

I guess you could try the :r option to have OSQL read sub-scripts from a mother script. The
sub-scripts cannot have GO. A test is needed to verify that new connections will not be opened for
subscripts, use Profiler for that. Also, :r is not documented for OSQL, but I think it is for
SQLCMD. However, I don't think that error handling will be the easiest thing to accomplish.

Show quote
"Ole Kristian Bangås" <olekristian.ban***@masterminds.no> wrote in message
news:Xns9717A547BD7D7olekristianbangaas@207.46.248.16...
> "Marek" <nospam@nowhere.com> wrote in
> news:#BmMdSD8FHA.2676@TK2MSFTNGP15.phx.gbl:
>
>> Is there a way to process multiple SQL scripts in a single transaction
>> using osql.exe ?
>> Ideally, I'd like to be able to start transaction, execute multiple
>> sql scripts and commit transaction when all of them succeeded or
>> rollback when there was a failure.
>> I appreciate your help.
>
> As far as I know this is not possible in osql, but if you try sqlcmd from
> SQL Server 2005, I do believe that you can. However, I have not tried this.
> SqlCmd is also available in SQL Server 2005 Express, which is free.
>
> --
> Ole Kristian Bangås
> MCT, MCDBA, MCDST, MCSE:Security, MCSE:Messaging

AddThis Social Bookmark Button