How to add a Computed Checksum Column to a SQL Server Table

To add a Computed Column as CHECKSUM of another column in a SQL Server Table, use the following code:

ALTER TABLE Table_Name
ADD Checksum_Column_Name AS CHECKSUM(Column_Name);
GO

To add a Computed Column as CHECKSUM of multiple columns in a SQL Server Table, use the following code:

ALTER TABLE Table_Name
ADD Checksum_Column_Name AS CHECKSUM(Column1, Column2, Column3,...);
GO

add_checksum_column

You can see that the Checksum column is added to the table:

checksum_column

To see the specification of the computed checksum column, right click on the table in the Object Explorer, choose 'Design':

checksum_column_table_design

...and click on the 'Column Name' to see 'Computed Column Specification' in the 'Column Details':

computed_column_specification

If the post helped you, please share it:
Pin It

1 comment to How to add a Computed Checksum Column to a SQL Server Table

  • swati

    i have a query ...y isnt my code running
    CREATE EVENT chk_sum ON SCHEDULE EVERY 10 SECOND DO INSERT INTO chksum VALUES (1,checksum table mydb1);

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">