SQL Server 2008 failed to update or insert a view or function

Source: Internet
Author: User
Tags table name

Environment: SQL Server 2008 R2

Problem: The update or insert of the view or function ' XXX ' failed because it contains a derived domain or a constant field to resolve

To create a view command:

Create View D_s_g (Sno,avg_grade)  
as
select Sno,avg (grade) from  
SC  
Group by Sno;

Reason: Views view does not allow modification.

Workaround: Recreate a table with the same structure content.

Execute the following command:

--d_s_t is the table name, D_s_g is the view name  
SELECT * into d_s_t from D_s_g where 1<>1 inserts into the  
      
d_s_t select * from D_s_g

Description: The table name (d_s_t) is different from the previous table name and view name because it is a SQL Server object.

Explanation: This is a view mechanism because the view that is created has other formal changes that are calculated for its property values, and changes to the view are ultimately manifested as changes to the table that do not exist in the table, or properties that are not the same in nature.

Related Article

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.