How to SET ARITHABORT ON for connections in Linq To SQL

Posted by Laurence on Stack Overflow See other posts from Stack Overflow or by Laurence
Published on 2010-06-03T23:20:55Z Indexed on 2010/06/15 22:22 UTC
Read the original article Hit count: 330

By default, the SQL connection option ARITHABORT is OFF for OLEDB connections, which I assume Linq To SQL is using. However I need it to be ON. The reason is that my DB contains some indexed views, and any insert/update/delete operations against tables that are part of an indexed view fail if the connection does not have ARITHABORT ON. Even selects against the indexed view itself fail if the WITH(NOEXPAND) hint is used (which you have to use in SQL Standard Edition to get the performance benefit of the indexed view).

Is there somewhere in the data context I can specify I want this option ON? Or somewhere in code I can do it??

I have managed a clumsy workaround, but I don't like it .... I have to create a stored procedure for every select/insert/update/delete operation, and in this proc first run SET ARITHABORT ON, then exec another proc which contains the actual select/insert/update/delete. In other words the first proc is just a wrapper for the second. It doesn't work to just put SET ARITHABORT ON above the select/insert/update/delete code.

© Stack Overflow or respective owner

Related posts about linq-to-sql

Related posts about arithabort