SQL Server changes the column data type in the table data type view.

Source: Internet
Author: User
Today, a vendor asked me a question. If you want to change the data type of a field in a table, whether it is a field type in view also responds to automatic changes. At that time, I thought it would be changed automatically. However, the vendors said they had tried and won't change it. They asked me if I had any other choice but to try again. At that time, I thought of the storage process sp_refreshview for refreshing the view and asked them to give it a try. After execution, the Data Type in the view is updated. In this example, we can see that the field type in the view is not synchronized except the view in Schema-bound. description found by msdn: updates the metadata for the specified non-schema-bound view. persistent metadata for a view can become outdated because of changes to the underlying objects upon which the view depends. therefore, when creating a view, the system stores the field type of the field at that time. Even if the field type is changed later, the SQL server does not automatically update the view. You need to manually update the view. Therefore, it is recommended that you do not use select * when creating a view. In addition, you can use schemabinding to select a table.

 
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.