Issues with executing stored procedure exceptions

Source: Internet
Author: User

Yesterday has been tangled in the implementation of the problem of the stored procedure exception, and later wrote a demo test, and went to the Internet to find information, finally solved the problem.

When you try to update a table that is referenced by an indexed view on SQL Server, you may be recycled to the following error

INSERT failed because the settings for the following set options are incorrect: ' ARITHABORT '

When you create or manipulate an index on a computed column or indexed view, the SET ansi_nulls must also be on. If SET ansi_nulls is OFF, the CREATE, UPDATE, INSERT, and DELETE statements on the indexed table on the computed column or indexed view will fail. SQL Server will return an error listing all SET options that violate the required values. Also, when the SELECT statement is executed, if SET ansi_nulls is OFF, SQL Server ignores the index values on the computed column or view and resolves the selection as if there were no such indexes on the table or view.

Solution:

1. You must set ARITHABORT on before TSQL, the code is as follows

Set ARITHABORT on
GO
INSERT into TA.

2. In ADO, you can write in this way (C # code)

Myconnection.execute ("SET ARITHABORT on");

If you're feeling a lot of trouble or can't change for some reason, you can try modifying the SQL Server server option

3.exec sp_dboption ' Yourdb ', ' ARITHABORT ', ' true '

It's OK

4.ALTER DATABASE Yourdb
SET ARITHABORT on

Issues with executing stored procedure exceptions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.