Display all instruction HTML data from an SQL database
Use the READTEXT function to retrieve all data in the Instruction HTML column for a specified record number. These steps represent a sample query and explain how to modify the query so that it will produce an HTML file.
To display all instruction HTML data from an SQL database
:- In Query Analyzer go to theTools > Options > Resultstab and clear thePrint column headers (*)option. SelectApplyand thenOKto close the dialog box.
- From theQuerymenu, selectResults to File.
- Enter this BHBATCHHIS 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*/BEGINSET NOCOUNT ONDECLARE@txtptrval VARBINARY(16),@offsetval INT,@bufferval INT,@maxval INTSELECT @txtptrval = TEXTPTR(bhbatchhis.InstructionHTML)FROMbhbatchhisWHERE recordno = '5817'SELECT @offsetval = 0SELECT @bufferval = 255SELECT @maxval = DATALENGTH(bhbatchhis.InstructionHTML) / 2-1FROMbhbatchhisWHERE recordno = '5817'--PRINT 'Total length of column: '--PRINT '------'--PRINT @maxval--PRINT ''-- Last chunk, reduce buffer size to the nChars remainingIF (@offsetval + @bufferval) > @maxvalBEGINSELECT @bufferval = @maxval - @offsetval--PRINT 'Last chuck... buffer size remaining is:'--PRINT '------'--PRINT @buffervalENDWHILE @offsetval < @maxvalBEGINREADTEXT bhbatchhis.InstructionHTML @txtptrval @offsetval@bufferval--PRINT 'Data started at character position'--PRINT @offsetvalSELECT @offsetval = @offsetval + @bufferval--PRINT 'Data ended at character position'--PRINT @offsetval--PRINT ' '-- Last chunk, reduce buffer size to the get the last nCharsremainingIF (@offsetval + @bufferval) > @maxvalSELECT @bufferval = @maxval - @offsetval + 1ENDSET NOCOUNT OFFEND
- In the query, edit the WHERE clause to specify therecordnoto view the InstructionHTML.
- Run the query and save the results to a file name, such asOutput.html.TIP:Be sure to specify the.htmlextension, change theSave as typetoAll Files (*.*), and change theFile FormattoANSI.
- In Windows Explorer, double-click the .html file to view the page in the browser.
Provide Feedback