From Dennis Morin about economy…

By a complete accident, I just found a quote from Dennis Morin, a co-founder of Wonderware:

“My attitude about the recession and GDP and all of that? Quite frankly, I ignore it totally. I do not factor the economic environment into my business plans whatsoever. I don’t like sitting around like a victim of external things beyond my control.”

I find it strangely inspiring…

How to retrieve wide-history data from Wonderware Historian using a stored procedure

Below is an example of a stored procedure that will retrieve wide-history data from Wonderware Historian (formerly known as IndustrialSQL Server):

CREATE PROCEDURE HistoryData
@StartDateTime datetime,
@EndDateTime datetime,
@Tags varchar(500) = ‘[SysDateDay], [SysDateMonth], [SysDateYear]’
–above: @Tags is an optional parameter, value after the equal sign is the default value if @Tags is omitted
AS
BEGIN
SET NOCOUNT ON
DECLARE @SQLString varchar(1000)
SET @SQLString = ‘SET QUOTED_IDENTIFIER OFF ‘
SET @SQLString = @SQLString + ‘SELECT * FROM OPENQUERY(INSQL, ‘
SET @SQLString = @SQLString + + ‘"SELECT DateTime = convert(nvarchar, DateTime, 21), ‘ + @Tags + ‘ ‘
SET @SQLString = @SQLString + ‘FROM WideHistory WHERE wwRetrievalMode = ”Cyclic” AND wwResolution = 1000 AND wwVersion = ”Latest” ‘
SET @SQLString = @SQLString + ‘AND DateTime >= ‘ + CHAR(39) + CAST(@StartDateTime AS varchar(50)) + CHAR(39)
SET @SQLString = @SQLString + ‘ AND DateTime <= ‘ + CHAR(39) + CAST(@EndDateTime AS varchar(50)) + CHAR(39) + ‘")’
EXEC (@SQLString)
END

The procedure accepts 3 parameters:
– Start date/time
– End date/time
– optional comma separated list of tag – so that you can run it for different set of tags

To install the procedure just run the script above against your Historian’s Runtime database from within SQL Server Management Studio.

And here’s how you execute the command:

EXEC HistoryData ‘20081027 21:04:00′,’20081027 21:07:00’, ‘SysTimeSec, SysDateDay’

But you can also skip the 3rd parameter and run it this way:

EXEC HistoryData ‘20081027 21:04:00′,’20081027 21:07:00’