|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
OSQL.exe questionIs 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. "Marek" <nospam@nowhere.com> wrote in As far as I know this is not possible in osql, but if you try sqlcmd from 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. 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
Show quote
"Ole Kristian Bangås" <olekristian.ban***@masterminds.no> wrote in And as Tibor so kindly answered in another group: You can download SqlCmd 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. 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 > 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 quoteTibor Karaszi, SQL Server MVP http://www.karaszi.com/sqlserver/default.asp http://www.solidqualitylearning.com/ "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 |
|||||||||||||||||||||||