├── HistorianClient ├── readme.md ├── DecryptServerlist.ps1 ├── RenameHistorianInExcelFiles.ps1 └── RenameTrendServer.ps1 ├── README.md ├── Administration ├── CharacterizeTagVersions.sql ├── DeleteOrphanedAppServerNamespace.sql ├── AnalyzeReplicationQueue ├── DeleteOldTags.sql ├── CharacterizeResourceUsage.sql ├── IMS 577414 - Check History Blocks.ps1 ├── SummarizeSQLClientLoad.sql ├── CheckSQLExpressImpact.sql ├── ShowTimeZoneInfo.ps1 ├── MultilingualDescriptions.sql ├── ExportHistoryToFastLoadCSV.sql ├── ExportInsightCharts.sql ├── AddMissingReplicatedTags.sql ├── ReplicationBackfillSP.sql └── ClientUsageTracking.sql └── Queries ├── StateSummariesWhenNoChange.sql ├── HourOfDayStatistics.sql ├── SummaryDataBasedOnPublicGroup.sql ├── wwkbAnyAllDiscrete.sql ├── SliceBy.sql ├── wwkbThresholdExtrema.sql └── wwkbExportToFastLoadCSV.sql /HistorianClient/readme.md: -------------------------------------------------------------------------------- 1 | Historian Client Tools 2 | ====================== 3 | 4 | A set of Powershell scripts for use with Wonderware/AVEVA Historian Client. 5 | 6 | Renaming Historian Servers 7 | -------------------------- 8 | 9 | When replacing/upgrading Historian servers, you my sometimes need to use a new name for the server, which creates a problem for Trend files and spreadsheets referencing the old name. There are scripts for changing the name of the Historian server referenced in ".aaTrend" file and in Excel files using the classic "Workbook" add-in (as opposed to the newer "Task Pane" add-in). 10 | 11 | Unsupported 12 | ----------- 13 | 14 | The primary implications of being UNSUPPORTED are: 15 | 16 | 1. These scripts have had LIMITED testing and may not work completely as intended and may have unintended side effects. 17 | 1. They include NO WARRANTY OF ANY KIND. AVEVA Group plc assumes NO responsibility for these scripts or any unintended consequences of using them. 18 | 1. By using them, you assume FULL responsibility for the consequences. 19 | 1. The scripts/objects may fail to work following a product update (patch, service pack, major release) that makes changes to existing database objects. 20 | 1. Wonderware/AVEVA assumes no responsibility to answer questions or assist with the use of the scripts themselves (although, to the degree they leverage standard product features, those are of course supported). 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Wonderware Historian Tools 2 | ========================== 3 | 4 | This is a collection of mostly SQL Server queries that work with Wonderware Historian to extract useful information. Most are packaged as stored procedure "CREATE" scripts and add UNSUPPORTED objects to your "Runtime" database. Except as may be noted in specific scripts, the additions do not alter existing database objects, only add new ones alongside the standard product ones. 5 | 6 | As a convention, database objects created by these scripts use the "wwkb" prefix in the name (Wonderware Knowledge Base), a holdover from when there was a set of utilities distributed on a "knowledge base" CD. 7 | 8 | Unsupported 9 | ----------- 10 | 11 | The primary implications of being UNSUPPORTED are: 12 | 13 | 1. These scripts have had LIMITED testing and may not work completely as intended and may have unintended side effects. 14 | 1. They include NO WARRANTY OF ANY KIND. AVEVA Group plc assumes NO responsibility for these scripts or any unintended consequences of using them. 15 | 1. By using them, you assume FULL responsibility for the consequences. 16 | 1. The scripts/objects may fail to work following a product update (patch, service pack, major release) that makes changes to existing database objects. 17 | 1. The objects will not be automatically recreated in a new "Runtime" database. 18 | 1. Wonderware/AVEVA assumes no responsibility to answer questions or assist with the use of the scripts themselves (although, to the degree they leverage standard product features, those are of course supported). 19 | -------------------------------------------------------------------------------- /Administration/CharacterizeTagVersions.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Characterize Tag Version Growth 3 | =============================== 4 | Frequent updates to tag meta data (engineering units, description, etc.) can degrade performance 5 | due to the growth in "tag versions". These "tag versions" are captured in the "TagHistory" table. 6 | These queries help characterize those meta data changes, which may point to some accidental changes. 7 | Revised: 9-May-2019 8 | By: E. Middleton 9 | */ 10 | use Runtime 11 | 12 | -- This shows the tags with the most changes and calls out the most likely properties to be triggering them 13 | select TagName, 14 | Versions=count(*), 15 | Descriptions=count(distinct [Description]), 16 | Units=count(distinct Unit), 17 | MinEUChanges=count(distinct MinEU), 18 | MaxEUChanges=count(distinct MaxEU), 19 | First=min(DateCreated), 20 | Last=max(DateCreated), 21 | AvgLifeInSecs=datediff(second,min(DateCreated),max(DateCreated))/1.0/count(*) 22 | from TagHistory 23 | group by TagName 24 | having count(*)>1 25 | order by Versions desc, Descriptions desc 26 | 27 | -- This query helps identify the time period when the most changes occurred for each tag. 28 | -- Further refine this be changing all 4 of the "month" literals below to "day" or "hour" 29 | -- May also want to narrow the period or tag list with changes to the WHERE clause 30 | select Beginning=dateadd(month, datediff(month, 0, DateCreated), 0), TagName, Versions=Count(*) 31 | from TagHistory 32 | where TagName like '%' 33 | and DateCreated between '2000-01-01' and getdate() 34 | group by dateadd(month, datediff(month, 0, DateCreated), 0), TagName 35 | having count(*)>5 36 | order by Versions desc 37 | 38 | 39 | -------------------------------------------------------------------------------- /HistorianClient/DecryptServerlist.ps1: -------------------------------------------------------------------------------- 1 | # This PowerShell script creates an unecrypted version of the current user's "servers.xml" file. 2 | # 3 | # It must be run from the 32-bit PowerShell command line: 4 | # 5 | # Usage: 6 | # 7 | # powershell -sta DecryptServerList.ps1 8 | # 9 | # This script is UNSUPPORTED and is released "as is" without warranty of any kind. 10 | # 11 | # 21-Mar-2023 12 | # E. Middleton 13 | 14 | 15 | if (!([System.Threading.Thread]::CurrentThread.GetApartmentState() -eq "STA")) { 16 | Write-Host "*** This must run as a single-threaded script. Run this from within PowerShell with:" 17 | Write-Host " powershell -STA