Back

Topic

[KB1042]Simple query to count record in SQL Server grouped by variable name

Tags: MSSqlServer, SQL Server

5 years ago
By FC
Options
Print
Applies to:

PcVue 8.10 onwards


Summary:

A good practice for SQL Server database size optimization is to investigate which tags are recorded more often than others.

This allows for example to increase Time filtering, use Deadband or inhibiting bit as a mechanism to save space.


Details:

In order to count how many records are present on a particular table for any PcVue variable, following query can be used:

use SampleProject_DB1

SELECT
Name,
COUNT(*) Qty
FROM
dbo.TRENDTABLE1
GROUP BY
Name
ORDER BY Qty

where SampleProject_DB1 is the name of your database, and TRENDTABLE1 the name of the table to check.


Created on: 05 Nov 2019 Last update: 13 May 2024