0

Code:

DECLARE @resultLast int, @siparisID nvarchar(21)
SET @siparisID = 2487

EXEC sp_executesql N'select * from OPENQUERY([MYSERVER],''Select  ( [MYDB].[dbo].[FN_SIPARIS_YUKLEME_TUTARI](@siparisID , 20 , 
                    [MYDB].[dbo].[FN_DATE_CONVERT_TO_DATE]( GETDATE()) , ''''BUY''''))'' )', @siparisID,
                N'@resultLast int output', @resultLast output;

I am trying to fetch data from linked server function. Also i need to send @siparisID parameter. I am getting incorrect syntax error. Help please...

Error:

Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '2487'.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

0

You've defined @siparisID nvarchar(21) - but you're setting it to a numerical datatype.

So either define it as a numeric datatype like int or decimal(p,s):

DECLARE @siparisID INT
DECLARE @siparisID BIGINT
DECLARE @siparisID DECIMAL(16,2)

or else change the initialisation to

SET @siparisID = N'2487';
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459