<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Useful SQL Queries on Audit Logs in Product Forum</title>
    <link>https://community.blueprism.com/t5/Product-Forum/Useful-SQL-Queries-on-Audit-Logs/m-p/85843#M36784</link>
    <description>This thread is created to enable the community members play around with AuditLog entries to get some meaningful data.&lt;BR /&gt;&lt;BR /&gt;Each post will contain one such query and it's explanation.&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Vivek Goel&lt;BR /&gt;CoE Lead Architect&lt;BR /&gt;Asia/Singapore&lt;BR /&gt;"If you like this post, please press the "Recommend" Button.&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
    <pubDate>Thu, 06 Feb 2020 04:46:00 GMT</pubDate>
    <dc:creator>vivek.kumar.goel</dc:creator>
    <dc:date>2020-02-06T04:46:00Z</dc:date>
    <item>
      <title>Useful SQL Queries on Audit Logs</title>
      <link>https://community.blueprism.com/t5/Product-Forum/Useful-SQL-Queries-on-Audit-Logs/m-p/85843#M36784</link>
      <description>This thread is created to enable the community members play around with AuditLog entries to get some meaningful data.&lt;BR /&gt;&lt;BR /&gt;Each post will contain one such query and it's explanation.&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Vivek Goel&lt;BR /&gt;CoE Lead Architect&lt;BR /&gt;Asia/Singapore&lt;BR /&gt;"If you like this post, please press the "Recommend" Button.&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Thu, 06 Feb 2020 04:46:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/Useful-SQL-Queries-on-Audit-Logs/m-p/85843#M36784</guid>
      <dc:creator>vivek.kumar.goel</dc:creator>
      <dc:date>2020-02-06T04:46:00Z</dc:date>
    </item>
    <item>
      <title>RE: Useful SQL Queries on Audit Logs</title>
      <link>https://community.blueprism.com/t5/Product-Forum/Useful-SQL-Queries-on-Audit-Logs/m-p/85844#M36785</link>
      <description>&lt;STRONG&gt;Version:&lt;/STRONG&gt; BP 6.5 and above&lt;BR /&gt;&lt;STRONG&gt;Query Usage:&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt; To track changes to environment variable.&lt;BR /&gt;&lt;STRONG&gt;Description:&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;This query can be used to know &lt;STRONG&gt;who , when, which ,from what , to what --Changes on Environment variable&lt;BR /&gt;Disclaimer:&lt;/STRONG&gt; This may not be an optimized query. It's given just for knowledge sharing purpose.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;
&lt;PRE class="language-markup"&gt;SELECT [eventdatetime]
	   ,SUBSTRING([sNarrative],11,CHARINDEX('modified',[sNarrative],1)-13) as username
	   ,SUBSTRING([sNarrative],CHARINDEX('environment variable',[sNarrative],1)+22,(Len([sNarrative])-CHARINDEX('environment variable',[sNarrative],1)-22)) as env_var_name
       ,[sNarrative]
	   ,SUBSTRING([comments],CHARINDEX('Old Value: "',[comments],1)+12,CHARINDEX('", New Value:',[comments],1)-CHARINDEX('Old Value: "',[comments],1)-12) as old_value
	   ,SUBSTRING([comments],CHARINDEX('New Value: "',[comments],1)+12,LEN([comments])-CHARINDEX('New Value: "',[comments],1)-12-2) as new_value
	   ,[comments]
FROM [dbo].[BPAAuditEvents] 
where [sNarrative] like '%modified%environment variable%'
order by eventdatetime desc

&lt;/PRE&gt;
&lt;BR /&gt;&lt;STRONG&gt;Explanation:&amp;nbsp;&lt;/STRONG&gt;This query basically uses text manipulation (Sub Str and Len) functions to find out what was modified on the environment variable.&lt;BR /&gt;It picks up datetime, username &amp;amp; environment variable name from the sNarrative column , old value and new value from the comment column within Auditlog table.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;STRONG&gt;Example Output:&lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;
&lt;DIV class="media" style="overflow: hidden; zoom: 1;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="23802.png"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/23936iACAAE2E329EB14A6/image-size/large?v=v2&amp;amp;px=999" role="button" title="23802.png" alt="23802.png" /&gt;&lt;/span&gt;&lt;/DIV&gt;
&lt;BR /&gt;Hope it helps.&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Vivek Goel&lt;BR /&gt;CoE Lead Architect&lt;BR /&gt;Asia/Singapore&lt;BR /&gt;"If you like this post, please press the "Recommend" Button.&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Thu, 06 Feb 2020 04:50:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/Useful-SQL-Queries-on-Audit-Logs/m-p/85844#M36785</guid>
      <dc:creator>vivek.kumar.goel</dc:creator>
      <dc:date>2020-02-06T04:50:00Z</dc:date>
    </item>
    <item>
      <title>RE: Useful SQL Queries on Audit Logs</title>
      <link>https://community.blueprism.com/t5/Product-Forum/Useful-SQL-Queries-on-Audit-Logs/m-p/85845#M36786</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Version:&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;BP 5 and above&lt;/SPAN&gt;&lt;BR /&gt;&lt;STRONG&gt;Query Usage:&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;To track changes to schedule.&lt;/SPAN&gt;&lt;BR /&gt;&lt;STRONG&gt;Description:&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;SPAN&gt;This query can be used to know&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;who&amp;nbsp; retired which schedule and when&lt;BR /&gt;Disclaimer:&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;This may not be an optimized query. It's given just for knowledge sharing purpose.&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE class="language-markup"&gt;SELECT [eventdatetime] 
      ,SUBSTRING([sNarrative],11,CHARINDEX('retired',[sNarrative],1)-13) as username
      ,SUBSTRING([sNarrative],CHARINDEX('schedule',[sNarrative],1)+10,Len([sNarrative])-CHARINDEX('schedule',[sNarrative],1)-10) as scheduleName
	  ,[sNarrative]
	  ,[comments]
FROM [dbo].[BPAAuditEvents] where sNarrative like '%retired%' order by [eventdatetime] desc
​&lt;/PRE&gt;
&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;STRONG&gt;Example Output:&lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;
&lt;DIV class="media" style="overflow: hidden; zoom: 1;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="23803.png"&gt;&lt;img src="https://community.blueprism.com/t5/image/serverpage/image-id/23935i3F5C8DF5E4B88C48/image-size/large?v=v2&amp;amp;px=999" role="button" title="23803.png" alt="23803.png" /&gt;&lt;/span&gt;&lt;/DIV&gt;
&lt;STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Vivek Goel&lt;BR /&gt;CoE Lead Architect&lt;BR /&gt;Asia/Singapore&lt;BR /&gt;"If you like this post, please press the "Recommend" Button.&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Thu, 06 Feb 2020 04:54:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/Useful-SQL-Queries-on-Audit-Logs/m-p/85845#M36786</guid>
      <dc:creator>vivek.kumar.goel</dc:creator>
      <dc:date>2020-02-06T04:54:00Z</dc:date>
    </item>
  </channel>
</rss>

