diff --git a/histdb/README.md b/histdb/README.md index c0809ed..201db03 100644 --- a/histdb/README.md +++ b/histdb/README.md @@ -20,6 +20,7 @@ Read-only reference. There's no code here — these files exist so an LLM can an ```text histdb/ README.md this file + connectioninfo.md Verified Runtime DB connection on this machine (server, sqlcmd recipe, sanity probes) 01-overview.md OLE DB provider, linked server, extension tables, four-part / OPENQUERY / OPENROWSET 02-syntax-limits.md Supported / unsupported SQL features, joins, sub-SELECTs, time-domain extensions overview 03-retrieval-modes.md Every wwRetrievalMode value (Cyclic, Delta, Full, Interpolated, BestFit, Average, Min, Max, Integral, Slope, Counter, ValueState, RoundTrip, Predictive, BoundingValue) @@ -33,6 +34,7 @@ histdb/ | Task | Go to | | --- | --- | +| Connect from this machine — server, instance, `sqlcmd` recipe, sanity probes | [`connectioninfo.md`](connectioninfo.md) | | Connect to Historian via SQL Server, pick a query style (four-part / view / OPENQUERY / OPENROWSET) | [`01-overview.md`](01-overview.md) | | What SQL syntax works and what doesn't (LIKE, IN, OR, joins, CONVERT, sub-SELECTs) | [`02-syntax-limits.md`](02-syntax-limits.md) | | Pick the right retrieval mode for the question being asked | [`03-retrieval-modes.md`](03-retrieval-modes.md) | diff --git a/histdb/connectioninfo.md b/histdb/connectioninfo.md new file mode 100644 index 0000000..f94f700 --- /dev/null +++ b/histdb/connectioninfo.md @@ -0,0 +1,87 @@ +# 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 + +```powershell +sqlcmd -E -S . -d Runtime -W -Q "" +``` + +- `-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): + +```powershell +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": + +```sql +-- 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`](01-overview.md#linking-insql-to-sql-server). + +| 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;`. +- **Python** — `pyodbc.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`](01-overview.md) and [`02-syntax-limits.md`](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/`](../grdb/)) are **different** SQL Server databases on the same instance. Don't cross-query.