Solved

binary checksum or checksum table

Posted on 2006-11-15
1
1,268 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

707 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

20 Experts available now in Live!

Get 1:1 Help Now