I have a SQL function that adds a number of business days into a specific date. The function is running ok in the local database server. However I'm having problem running the function from linked server.
Here's the parameters of my functions:
CREATE FUNCTION [dbo].[AddBizDays] (@Day SMALLINT, @StartDate DATE) RETURNS SMALLDATETIME
I'm following this suggestion: SQL Server: How to call a user-defined function (UDF) on linked server?
This is what I'm trying to call:
EXEC [Server1].DB1.dbo.sp_executesql
N'SELECT [dbo].[AddBizDays](@Day, @StartDate)',
'N@Day smallint, @StartDate date',
'@Day = 1',
'@StartDate = ''2024-10-01'''
OR
EXEC [Server1].DB1.dbo.sp_executesql N'SELECT [dbo].[AddBizDays](@Day,
@StartDate)','N@Day smallint, @StartDate date',
'@Day = 1, @StartDate = ''2024-10-01'''
I keep getting an error with supplying the parameters Procedure expects parameter '@params' of type 'ntext/nchar/nvarchar'.
N'@Day...'
not'N@Day...
. TheN
goes before the single quote, not after.@ParameterName = <Parameter Value>
. I suggest checking the linked question again; you haven't followed its directions.