Why do I have to SET ARITHABORT ON when using xml in sql server 2005?

Here's a solution I found to the ARITHABORT issue when calling a stored procedure with an xml input parameter from a .Net client.

using (var conn = new SqlConnection(dbConnectionString))  
{  
    SqlCommand command = new SqlCommand("[stored procedure name here]", conn);  
    command.CommandType = CommandType.StoredProcedure;  
    command.Parameters.AddWithValue("@parameter_name", parameter_xml_value);  

    conn.Open();  

    SqlCommand arithabortCommand = new SqlCommand("SET ARITHABORT ON", conn);  
    arithabortCommand.ExecuteNonQuery();  

    command.ExecuteNonQuery();  
    conn.Close();  
} // using (var conn = new SqlConnection(dbConnectionString))  

According to this thread (at the bottom), it could depend on your compatibility level:

http://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/a874b4b2-05ad-4066-9811-30939188d695


I'm thinking this statement from books online kind of hints at it: "SET ARITHABORT must be ON when you are creating or changing indexes on computed columns or indexed views." So the nodes method must be creating an indexed view internally or something. But this is just an educated guess.

Tags:

Sql Server

Xml