Troubleshooting Guide: Error 12344 — “Only Natively Compiled Modules Can Be Used with %S_MSG”
Why This Error Happens
This error occurs when a Transact-SQL statement or module attempts to reference a feature, object, or syntax element that is only supported within natively compiled modules (such as those used with memory-optimized tables in In-Memory OLTP). SQL Server 2025 enforces strict compilation boundaries between interpreted T-SQL and natively compiled modules, so mixing unsupported constructs—like certain system functions, cursors, or dynamic SQL—inside a natively compiled stored procedure triggers this validation failure. This typically stems from a schema migration, an upgraded compatibility level, or a module that was not properly rewritten to comply with native compilation restrictions.
Step-by-Step Resolution Guide
Step 1: Identify the Offending Module
- Open SQL Server Management Studio (SSMS) and connect to the affected instance.
- Run the following query to locate natively compiled objects and check their definitions:
SELECT name, object_id, type_desc
FROM sys.sql_modules
WHERE uses_native_compilation = 1;
- Review the module definition for unsupported elements (e.g.,
OPENROWSET, cursors, or non-deterministic functions).
Step 2: Review and Correct the Module Code
- Check the procedure or function for syntax not permitted in natively compiled modules, such as:
- Multi-statement table-valued functions
- Nested stored procedure calls outside native scope
- String or XML functions unsupported in native compilation
- Rewrite the logic using only supported T-SQL surface area for native modules, referencing the Native Compilation Compatibility List in SQL Server 2025 documentation (
C:\Program Files\Microsoft SQL Server\160\Tools\Binn\for local doc cache if installed offline).
Step 3: Recompile the Module
- Drop and recreate the natively compiled module using the corrected syntax:
DROP PROCEDURE IF EXISTS dbo.YourNativeProc;
GO
CREATE PROCEDURE dbo.YourNativeProc
WITH NATIVE_COMPILATION, SCHEMABINDING
AS BEGIN ATOMIC WITH (TRANSACTION ISOLATION LEVEL = SNAPSHOT, LANGUAGE = N'us_english')
-- corrected logic here
END;
GO
- Confirm compilation succeeds without triggering Error 12344.
Step 4: Validate Database Compatibility Level
- Ensure the database compatibility level supports native compilation features expected in SQL Server 2025:
SELECT compatibility_level FROM sys.databases WHERE name = 'YourDatabaseName';
- If outdated, update it:
ALTER DATABASE YourDatabaseName SET COMPATIBILITY_LEVEL = 170;
Alternative or Verification Steps
- After recompilation, execute the procedure manually (
EXEC dbo.YourNativeProc;) and confirm no Error 12344 appears in SQL Server Logs or Event Viewer underApplications and Services Logs > Microsoft > SQL Server. - If the issue persists, consider converting the problematic logic into a standard (interpreted) stored procedure instead of a natively compiled one, especially if the required functionality is not supported natively in SQL Server 2025.