Solved

binary checksum or checksum table

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
set default date format in mssql to mm/dd/yyyy 22 66
tempdb latch contention 12 47
sql server query from excel 3 57
grouping logic 6 46
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

914 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

13 Experts available now in Live!

Get 1:1 Help Now