Nature: Why can't SQL Server truncate table Variables

Source: Internet
Author: User

I suddenly thought of this problem recently and recorded it to consolidate my knowledge.

Tables, temporary tables, and table variables are used by many people. truncate Table @ table variables may report errors. I believe many people have encountered them, but there are few people who really think about why, after all, in most cases, most of us only need to use it, and do not need to know why. Moreover, domestic projects are always so tense that there is still a thirst for knowledge, it may also be subject to tasks, and performance appraisal has been rushed.

So why can't table variables be truncate? We need to understand the essence of the truncate command.Release the data page used to store table dataTo delete data. The table variable data is stored inMemoryInstead of in the disk, truncate table tries to release the"Data Page ",Of course, an error will be reported.

 

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.