DECLARE @LogDate AS BIGINT = dbo.GetUnixTime(GETUTCDATE()) 
DECLARE @queryId AS INTEGER = 10250
DECLARE @surveyXML nvarchar(MAX) 
 
DECLARE @releaseId integer 
SET @releaseId = (select releaseId from APP_Client where id = 2) 
 
DECLARE @temptbl table 
(
[Has Missing Flag] nvarchar(max)
)


IF @releaseId = 16
BEGIN 
 insert into @temptbl 
EXEC('SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; SET NOCOUNT ON; IF EXISTS
(
	SELECT 1 
	FROM	archGroupCopy AGC WITH(READUNCOMMITTED) 
			INNER JOIN ArchGroup AG WITH(READUNCOMMITTED) ON AGC.archGroupId = AG.id
	WHERE	(
				AG.flags & 32 /*CVA_SP_SIDB_BLOCK_LEVEL_FLAG*/ = 0 
				OR AG.SIBlockSizeKB = 0
			)
			AND AGC.dedupeFlags & 262144 /*CVA_SIDB_STORE_ENABLED_FLAG*/ > 0
)
BEGIN
     SELECT ''YES'' AS [Has Missing Flag]
END
ELSE
BEGIN
     SELECT ''NO'' AS [Has Missing Flag]
END ') 
 END
 
 SET @surveyXML = 
( SELECT 
(
SELECT [Has Missing Flag] AS '@Col_-2045496820' FROM @temptbl
 FOR XML PATH ('cf_MetricsQuery10250'), type
)
  FOR XML PATH ('SurveyResults') 
)

DECLARE @EndTime AS BIGINT = dbo.GetUnixTime(GETUTCDATE()) 
SET @outputXML = (SELECT @queryId AS '@QueryId', @EndTime AS '@LogDate', (@EndTime - @LogDate) AS '@QueryRunningTime', @surveyXML FOR XML PATH('Rpt_CSSXMLDATA')) 
