title: Msg 102, Level 15, State 1, Line 6 Incorrect syntax near '='
body: <p>I need help with my stored procedure, I kept getting this Error, but I can't find the real error.  </p>
  
  <blockquote>
    <p>Msg 102, Level 15, State 1, Line 6
    Incorrect syntax near '='.</p>
  </blockquote>
  
  <p>My code:</p>
  
  <pre><code>    DECLARE @Batch_Num_For_Sending BIGINT;
  DECLARE @IPLocal NVARCHAR(15);
  
  SET @IPLocal = (
          SELECT Local_IPAddress
          FROM [RFIDSync].[dbo].[RFID_LinkSetup]
          WHERE Link_ID = 1
          );
  
  DECLARE @IPMain NVARCHAR(15);
  
  SET @IPMain = (
          SELECT Main_IPAddress
          FROM [RFIDSync].[dbo].[RFID_LinkSetup]
          WHERE Link_ID = 1
          );
  
  DECLARE @LocationProj NVARCHAR(50);
  
  SET @LocationProj = 'Test_Project';
  SET @Batch_Num_For_Sending = (
          SELECT MIN(Batch_Id)
          FROM [db].[dbo].[LOCALBATCH]
          WHERE Batch_Status = 0
          )
  
  SELECT @Batch_Num_For_Sending
  
  EXEC (
          '
          SELECT Sync_Batch_Num FROM OPENQUERY([' + @IPMain + '\SQLEXPRESS], ''SELECT Sync_Batch_Num
              FROM [db].[dbo].[SYNCBATCH] WHERE [Location] = ''''' + @LocationProj + '''''
              '')
              WHERE Sync_Batch_Num = ' + @Batch_Num_For_Sending + '
          '
          )
  </code></pre>