Why am I getting thins error?
Msg 102, Level 15, State 1, Line 76Incorrect syntax near '@RemoteServer'.
SET @strSql = 'SELECT DISTINCT TOP ' + @numRecordsToProcess + ' ' + '
i.[MasterKey],
i.[OriginalKey],
i.[ImageName],
i.[ImageBatchType],
i.[NoOfPages],
i.[ImageSize],
i.[Station],
i.[UserId],
i.[ServerPath],
i.[Path],
i.[Status],
i.[VirtualPath],
i.[LocalImageRootPath],
i.[GroupKey],
dt.[TypeKey] AS [DocumentType]
FROM [ImageMaster] i(NOLOCK)
INNER JOIN [ImagePage] ip(NOLOCK) ON i.[MasterKey] = ip.[MasterDocument]
INNER JOIN DocumentTypes dt(NOLOCK) ON ip.PageType = dt.TypeKey
WHERE i.[CreateDateTime] >= DATEADD(Year,-2,GETDATE())
AND NOT EXISTS
(SELECT [MasterKey]
FROM ['@RemoteServer'].[Interact].[dbo].[tblImageTransfer3xLogging] lg (NOLOCK)
WHERE i.[MasterKey] = lg.[MasterKey] AND lg.[Processed] = ''Y'')'