Solved

binary checksum or checksum table

Posted on 2006-11-15
1
1,270 Views
Last Modified: 2008-02-01
Hi
What is binary checksum or checksum table and where can we use this.

Thanks
0
Comment
Question by:atwork2003
1 Comment
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 500 total points
ID: 17948441
Did u  check books online, there are few exampples given



A. Use BINARY_CHECKSUM to detect changes in the rows of a table.
This example uses BINARY_CHECKSUM to detect changes in a row of the Products table in the Northwind database.

/*Get the checksum value before the values in the specific rows (#13-15) are changed.*/
USE   Northwind
GO
CREATE   TABLE TableBC (ProductID int, bchecksum int)
INSERT   INTO TableBC
         SELECT   ProductID, BINARY_CHECKSUM(*)
         FROM      Products
/*TableBC contains a column of 77 checksum values corresponding to each row in the Products table.*/

--A large company bought products 13-15.
--The new company modified the products names and unit prices.
--Change the values of ProductsName and UnitPrice for rows 13, 14, and 15 of the Products table.*/
UPDATE   Products
SET   ProductName='Oishi Konbu', UnitPrice=5
WHERE   ProductName='Konbu'

UPDATE   Products
SET   ProductName='Oishi Tofu', UnitPrice=20
WHERE   ProductName='Tofu'

UPDATE   Products
SET   ProductName='Oishi Genen Shouyu', UnitPrice=12
WHERE   ProductName='Genen Shouyu'

--Determine the rows that have changed.
SELECT   ProductID
FROM      TableBC
WHERE   EXISTS   (
      SELECT   ProductID
      FROM      Products
      WHERE      Products.ProductID = TableBC.ProductID
      AND   BINARY_CHECKSUM(*) <> TableBC.bchecksum)

Here is the result set:

ProductID
13
14
15

0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now