DECLARE @LogDate AS BIGINT = dbo.GetUnixTime(GETUTCDATE()) DECLARE @queryId AS INTEGER = 10278 DECLARE @surveyXML nvarchar(MAX) DECLARE @releaseId integer SET @releaseId = (select releaseId from APP_Client where id = 2) DECLARE @temptbl table ( [Key Exists] int,[Key Value] nvarchar(max) ) IF @releaseId = 16 BEGIN insert into @temptbl EXEC('SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; SET NOCOUNT ON; DECLARE @isKeyExists INT = 0 DECLARE @keyValue VARCHAR(1024) = '''' SELECT @isKeyExists = 1, @keyValue = value FROM GXGlobalParam WHERE name=''CSAllowBuiltInCerts'' SELECT @isKeyExists AS ''Key Exists'', @keyValue AS ''Key Value'' ') END SET @surveyXML = ( SELECT ( SELECT [Key Exists] AS '@Col_1128557949',[Key Value] AS '@Col_-1472597968' FROM @temptbl FOR XML PATH ('cf_MetricsQuery10278'), 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'))