Why is this returning a blank screen?
SET ANSI_NULLS ONGO
SET QUOTED_IDENTIFIER ON
GO
--CREATE PROCEDURE <Procedure_Name, sysname, ProcedureName>
DECLARE
@numRecordsToProcess INT,
@RemoteServer VARCHAR(50)
--AS
--BEGIN
SET NOCOUNT ON;
DECLARE @StrSql VARCHAR(6000)
SET @numRecordsToProcess = 0
IF @numRecordsToProcess != 0
BEGIN
SET @strSql = N'SELECT DISTINCT TOP ' + convert(varchar(9), @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'')'
END
ELSE
BEGIN
SET @strSql = N'SELECT DISTINCT TOP ' + convert(varchar(9), @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'')'
END
PRINT @StrSql
EXEC (@StrSql)
- Edited by soldierfc 11 hours 27 minutes ago