Rockwell Automation FactoryTalk Historian Classic for Batch User Guide User Manual

Page 33

Advertising
background image

Collecting Batch Data Chapter 3

If you are archiving data to an SQL database, you must use the

READTEXT function to retrieve all data in the Instruction HTML
column for a specified record number. The following steps provide a
sample query and explain how to modify the query that will produce
an .html file for viewing in a browser:

1. In Query Analyzer go to the Tools > Options > Results tab

and clear the Print column headers (*) option. Click Apply
and then OK to close the dialog box.

2. From the Query menu, select Results to File.
3. Copy the following example query into a blank query window:

/*

-- Displays the contents of a text column in a 255-character
wide query window

-- @txtptrval is the text pointer value for the specified
text column

-- @offsetval is the offset value and represents the
starting

-- position within a text column

-- @bufferval represents the amount of text to put in the
row

-- in this case, it is set to 255 because isql/w only displays

-- 255 characters in a row

-- @maxval is the full length of the entire text column

*/

BEGIN

SET NOCOUNT ON

DECLARE

@txtptrval VARBINARY(16),

@offsetval INT,

@bufferval INT,

@maxval INT

SELECT @txtptrval =
TEXTPTR(bhbatchhis.InstructionHTML)

FROM bhbatchhis

WHERE recordno = '5817'

SELECT @offsetval = 0

SELECT @bufferval = 255

SELECT @maxval =
DATALENGTH(bhbatchhis.InstructionHTML) / 2-1

How To Display All
Instruction HTML Data From
an SQL Database

Rockwell Automation Publication BHIST-UM011A-EN-E-June 2014

33

Advertising