Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我可以在内存优化过程中使用表变量吗?
DECLARE @tvTableD TABLE ( Column1 INT NOT NULL , Column2 CHAR(10) );
这里说,不。 https://docs.microsoft.com/en-us/sql/relational-databases/in-memory-oltp/transact-sql-constructs-not-supported-by-in-memory-oltp?view=sql-server- 2017#natively-compiled-stored-procedures-and-user-defined-functions
有人可以确认吗?
您链接了文档:
“表类型不能与变量声明内联声明。表类型必须使用 CREATE TYPE 语句显式声明。”
本文向您展示如何将内联表变量声明替换为表类型:
CREATE TYPE dbo.typeTableD AS TABLE ( Column1 INT NOT NULL INDEX ix1, Column2 CHAR(10) ) WITH (MEMORY_OPTIMIZED = ON);
通过使用内存优化更快的临时表和表变量