Files
wwtools/histdb/connectioninfo.md
T
Joseph Doherty 5a78ec5a76 histdb: add connectioninfo.md with verified Runtime DB access
Captures the working SQL Server connection state on this machine:
server (localhost / MSSQLSERVER), database (Runtime), Windows-auth
account (DESKTOP-6JL3KKO\dohertj2, sysadmin), the sqlcmd recipe, four
paste-and-run sanity probes including an end-to-end INSQL retrieval,
linked-server roles (INSQL, INSQLD), and alternate client paths
(SSMS / PowerShell / ODBC / pyodbc).

Linked from histdb/README.md Layout and Resource index per
DOCS-GUIDE.md. Mirrors the pattern grdb/connectioninfo.md uses for
its own DB.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 19:28:25 -04:00

4.0 KiB

Historian Runtime DB — Connection Information

Verified working state on this machine. Capture date: 2026-05-03.

Connection parameters

Parameter Value
Server localhost (default instance, MSSQLSERVER)
Database Runtime
Port 1433 (default)
Authentication Windows integrated
Account DESKTOP-6JL3KKO\dohertj2
Server role sysadmin (full access; AVEVA aaUsers / aaPowerUsers / aaAdministrators group checks short-circuit through sysadmin)
SQL Server 2017 Express, 14.0.2105.1 (RTM-GDR, KB5084819)

sqlcmd recipe

sqlcmd -E -S . -d Runtime -W -Q "<your SELECT>"
  • -E — Windows authentication.
  • -S . — local default instance (equivalent to localhost).
  • -d Runtime — Historian DB.
  • -W — strip trailing whitespace from columns.

For pipe-separated machine-readable output, add -s "|" -h -1 (the -h -1 suppresses headers; drop it to keep them):

sqlcmd -E -S . -d Runtime -W -s "|" -Q "..."

Sanity probes

These four queries together verify "I'm in the right DB and can reach Historian":

-- 1. Identify
SELECT @@SERVERNAME AS server, DB_NAME() AS db, SUSER_SNAME() AS [user];

-- 2. Tag tables exist (numbers will differ — non-zero is the point)
SELECT 'Tag'         AS tbl, COUNT(*) AS rows_ FROM Tag         UNION ALL
SELECT 'AnalogTag',         COUNT(*)          FROM AnalogTag    UNION ALL
SELECT 'DiscreteTag',       COUNT(*)          FROM DiscreteTag  UNION ALL
SELECT 'StringTag',         COUNT(*)          FROM StringTag;

-- 3. Linked servers (both should return one row)
SELECT name FROM sys.servers WHERE name IN ('INSQL', 'INSQLD');

-- 4. End-to-end OLE DB pull through INSQL
SELECT TOP 3 TagName, DateTime, Value
FROM History
WHERE TagName = 'SysTimeSec'
  AND DateTime >= DATEADD(MINUTE, -1, GETDATE())
  AND DateTime <= GETDATE()
  AND wwRetrievalMode = 'Cyclic'
  AND wwCycleCount = 5;

If probe 4 returns rows, the full retrieval path is live.

Tags actually present (snapshot)

At capture date: 239 total tags (Tag), 219 analog, 18 discrete, 1 string. Useful built-ins for smoke-testing without depending on plant data: SysTimeSec, SysTimeMin, SysTimeHour, SysPulse, SysPerfCPUTotal, SysSpaceMain.

Linked servers

Both auto-installed by Historian. Documented in 01-overview.md.

Linked server Role
INSQL Primary alias for the Historian OLE DB Provider. Use this in four-part queries (INSQL.Runtime.dbo.History) and OPENQUERY(INSQL, '...').
INSQLD Identical alias used to satisfy SQL Server when the same query joins the legacy analog and discrete history tables.

Other client paths

  • SSMS / Azure Data Studio — point at server ., Windows auth, database Runtime.
  • PowerShell Invoke-Sqlcmd — needs the SqlServer module (this machine has SQLPS 14.0 only; install SqlServer from PSGallery if you want it). Equivalent: Invoke-Sqlcmd -ServerInstance . -Database Runtime -Query "...".
  • .NET / ODBC / ADO.NET — connection string Server=.;Database=Runtime;Integrated Security=SSPI;.
  • Pythonpyodbc.connect("Driver={SQL Server};Server=.;Database=Runtime;Trusted_Connection=yes;").

Caveats

  • The tag tables (Tag, AnalogTag, etc.) are real SQL Server tables — fast, normal joins, no wwXxx semantics. The history tables (History, Live, WideHistory, AnalogSummaryHistory, StateSummaryHistory, Events, HistoryBlock) are extension tables served by INSQL; they require the patterns in 01-overview.md and 02-syntax-limits.md.
  • A WHERE clause is mandatory on every extension table except HistoryBlock. Probe 4 above demonstrates the minimum acceptable shape (TagName + DateTime range + retrieval mode).
  • Runtime and the Galaxy Repository (covered by ../grdb/) are different SQL Server databases on the same instance. Don't cross-query.