It is a known fact, that checksum function can not be applied to text, ntext and image fields. But sometimes it is necessary to compare whether a value in a text field has changed (although it is not guaranteed that checksum generates a unique value, but it still could be used as a good estimator). This script computes checksum of the text field (has not been tested with ntext or images!). I think someone might find it useful. The only concern is that it does not perform greatly on the large strings (>1MB). Relatively small strings would provide a tolerable performance. But if one has to compare rows of the table field by field using checksums, text fields do not have to be excluded or truncated. The idea behind the function is very simple. It breaks text into chunks of 2000 characters (using substring(…) function). Then it records every chunk of text into a table variable. Identity field of the table variable will maintain correct order of every portion of data. After data splitting is complete, one can compute an aggregate checksum on the table variable using checksum_agg(binary_checksum(*)) expression. This expression is described in SQL Server BOL.
Creating a PDF from a Stored Procedure in SQL Server
A short but interesting article, the author has figured out a way to create a PDF from a stored procedure without using a third party library.
2019-09-20 (first published: 2003-08-26)
73,224 reads