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.