内存中的表和使用 SQL 服务器存储的过程中的正常表

Tables in memory and tables normal on procedure stored using SQL Server

我正在尝试将存储过程重写为本机编译的存储过程。程序参考4张表;这些表是普通表(非内存优化),我正在使用 2 个与之相关的视图。

是否可以在不将任何这些对象转换为内存优化表的情况下创建本机编译的存储过程?

不,本地编译的存储过程不能引用基于磁盘的表,只能引用内存优化的表。这是 Kalen Delaney 的书 SQL Server Internals: In-Memory OLTP:

中的引述

However, there are limitations on the T-SQL language constructs that are allowed inside a natively compiled stored procedure, compared to the rich feature set available with interpreted code. In addition, natively compiled stored procedures can only access memory-optimized tables and cannot reference disk-based tables.

除了 this 限制外,我在 Microsoft 官方文档中找不到明确的说明,这是本机编译的存储过程无法引用 "normal" 表这一事实的直接后果:

For memory-optimized tables, FOREIGN KEY constraints are only supported for foreign keys referencing primary keys of other memory-optimized tables.