Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

SQL Server continue on error

  • 10-08-2010 10: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