Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

SQL Server continue on error

  • 10-08-2010 11:10AM
    #1
    Closed Accounts Posts: 4,235 ✭✭✭


    Hey,

    Anyone else found a way around this. Big sql script to be ran on sql server but its cumulative so parts have already been ran before. In oracle world thats fine it will throw an error about a duplicate name but continue on running the rest of the file. In SQL Server it doesn't, first error it bombs out.

    Is there a switch to ignore errors and continue on processing the rest of the file?


Comments

  • Closed Accounts Posts: 1,759 ✭✭✭Dr.Silly


    iregk wrote: »
    Hey,

    Anyone else found a way around this. Big sql script to be ran on sql server but its cumulative so parts have already been ran before. In oracle world thats fine it will throw an error about a duplicate name but continue on running the rest of the file. In SQL Server it doesn't, first error it bombs out.

    Is there a switch to ignore errors and continue on processing the rest of the file?

    you can put a GO in between your statements.
    e.g

    insert into namestbl values ('a','b','22')
    go
    insert into namestbl values (1'''','b','22')
    go
    insert into namestbl values ('a','b','22')


    my second statement fails here, but the script will continue and 2 rows are inserted.


  • Closed Accounts Posts: 4,235 ✭✭✭iregk


    Ok cool, will give that a shot. I thought there was some switch in the osql command that you can specify continue on error or something...


  • Closed Accounts Posts: 1,759 ✭✭✭Dr.Silly


    am afraid not


  • Closed Accounts Posts: 910 ✭✭✭Jagera


    Or look at TRY.. CATCH


Advertisement