Troubleshooting Guide: SQL Server Error 441 – “Cannot use the ‘%ls’ function on a remote data source”
Why This Error Happens
This error occurs because SQL Server does not support the use of certain built-in functions—such as system functions, rowset functions, or functions with side effects—directly against a linked server or remote data source. It typically surfaces when a query attempts to execute a function like OPENQUERY, fn_helpcollations, or similar system-level functions remotely instead of locally. In most cases, this is caused by a poorly optimized distributed query or an application layer (like Power BI, SSIS, or a custom app under “Getting Data” workflows) generating T-SQL that pushes unsupported operations to the linked server.
Step-by-Step Resolution Guide
Step 1: Identify the Offending Query
- Open SQL Server Management Studio (SSMS) and enable SQL Server Profiler or use Extended Events to capture the exact query triggering Error 441.
- Look for function calls (e.g.,
NEWID(),RAND(),fn_...) embedded inside a distributed query referencing a linked server. - Confirm the query structure using:
SELECT * FROM OPENQUERY([LinkedServerName], 'SELECT ...')
Step 2: Rewrite the Query to Avoid Remote Function Execution
- Modify the query so that the restricted function is evaluated locally rather than being pushed to the remote server.
- Wrap the remote portion in a derived table or temp table first, then apply the function locally:
SELECT dbo.MyFunction(RemoteColumn)
FROM OPENQUERY([LinkedServerName], 'SELECT RemoteColumn FROM RemoteTable')
- Avoid placing system functions directly inside the
OPENQUERYor four-part naming convention call.
Step 3: Verify Linked Server Configuration
- Navigate to SSMS > Server Objects > Linked Servers > [Your Linked Server] > Properties.
- Confirm that “RPC” and “RPC Out” are set to
Trueunder the Server Options tab. - Run the following to check current settings:
EXEC sp_serveroption 'LinkedServerName', 'rpc out', 'true';
Step 4: Update Provider and Driver Settings
- On Windows Server 2025/Windows 11, ensure the OLE DB provider (e.g., MSOLEDBSQL) is updated to the latest version via Microsoft Update Catalog.
- Check provider options at
SSMS > Server Objects > Linked Servers > Providers > [ProviderName]and ensure “Allow InProcess” is enabled if using certain providers.
Step 5: Restart SQL Server Services
- Open Services.msc and restart the SQL Server (MSSQLSERVER) service to apply configuration changes.
- Alternatively, run:
Restart-Service -Name 'MSSQLSERVER' -Force
Alternative or Verification Steps
- Re-run the original query that triggered Error 441; if resolved, the function should now execute without referencing the remote source directly.
- As an alternative, replace
OPENQUERYwithOPENROWSETor fully qualified four-part names combined with local temp tables to isolate remote data retrieval from function execution.