I am using SQL Server 2016 to write a stored procedure with dynamic SQL and sp_executesql
with multiple parameters.
CREATE PROCEDURE [dbo].[testsp] @ProductName nvarchar(250), @ProductDescription nvarchar(250)
AS
DECLARE @query NVARCHAR(MAX)
SET @query = 'EXEC (''INSERT INTO [dbo].[Products] ([ProductName], [ProductDescription]) VALUES (?,?)'', @ProductName, @ProductDescription) AT [linkedserver]'
EXEC sp_executesql @sql, N'@ProductName nvarchar(250), @ProductDescription nvarchar(250)', @ProductName, @ProductName;
Error: Must pass parameter number 2 and subsequent parameters as '@name = value'. After the form '@name = value' has been used, all subsequent parameters must be passed in the form '@name = value'
I need to make a jdbc call of the stored procedure.
call [dbo].[testsp](?,?)