Link to home
Start Free TrialLog in
Avatar of Jay Roy
Jay RoyFlag for United States of America

asked on

checksum autogeneration

hi guys
I want to create a table Customer with 4 columns

Customer
Id Name Price Checksum


checksum value needs to be autopopulated when an insert occurs
and on update of that row the checksum should update aswell
does sql server provide any such feature?

I am using md5 checksum in my java front end , so that way i can check if the row already exists in the table.

thanks
Avatar of Jay Roy
Jay Roy
Flag of United States of America image

ASKER

experts,
Can anyone please help with this. I want to know if checksum can be calculated and saved for each row

thanks
ASKER CERTIFIED SOLUTION
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jay Roy

ASKER

Thanks for responding..

By 'checksum' i mean a unique code for a row of data
So each row will have its own checksum or unique code.
I looked around and see that sql server has a checksum function so in my case for
above Customer table  it would be
CHECKSUM(Id,Name,Price);

how ever what i want to do is
when a new row is inserted into the Customer table create the CHECKSUM for it and insert it in the Checksum column
i tried something like

CREATE TABLE [ado].[CUSTOMER](
      [ID] [nvarchar](16) NULL,
      [Name] [nvarchar](100) NULL,
      [Price] [nvarchar](100) NULL,      
      [CheckSum] [nvarchar](100) DEFAULT CHECKSUM([ado].[CUSTOMER].ID,[CUSTOMER].Name,[CUSTOMER].Price)

but it doesnt seem to work.

Thanks
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jay Roy

ASKER

the point of this excercise is i have two tables

TableA and TableB
with exact same number of columns but different data

TableA
col1 col2 col3  checksum

TableB
col1 col2 col3  checksum


Now TableA gets refreshed every 30 minutes with new data from a remote database table

The new data which arrived in TableA needs to be inserted in TableB.

So what i have in mind is if each row has its own checksum in both the tables,
compare the checksum for each row in TableA v/s TableB

The checksum(s) in TableA missing in TableB are the new rows, so add them to TableB


Do you think my approach is wrong ?

thanks
What I had in my mind when expressing the opinion before didn't involve table synchronization.

Other experts here will be far more experienced than I am on this table synchronization need