Subscription Initialization throws Error "The option "INLINE=ON" is not valid for this function" which is incorrect

Refer this article The only solution worked for me was drop and recreate the UDF after upgrading to SQL 2019.

The inline_Type column from Sys.sql_modules will be 1 after your upgrade to SQL 2019. After you drop and recreate the UDF, the Inline_type will be 0 and the replication initialization works fine.


I encountered this issue while migrating a publication that includes some scalar UDFs from SQL 2016 to SQL 2019. Changing the database settings on the publisher database did not resolve the issue. And since the subscribers include older versions of SQL Server, adding "WITH INLINE=OFF" is not an option in the function definition. So my solution is to force the udf to not be inlineable by adding the following code within the function definition:

--Junk code to force is_inlineable to 0 
DECLARE @dummy DATETIME; SELECT @dummy = GETDATE()

If you do a select on sys.sql_modules, is_inlineable will show as 0, and the snapshot scripts will generate successfully.