SQLTeam.com | Weblogs | Forums

Update if any one column changes


#1

Greetings,

I am thinking of using BINARY_CHECKSUM(*) to check for changes on source table to compare with destination table in an ingest (ETL) process.

So when doing BINARY_CHECKSUM(*) is it doing over all columns in the table or the column in the select statment?

SELECT name, lastname, 
BINARY_CHECKSUM(*) bchecksum
FROM [IntegrationStaging].[dbo].SourceTable

#2

Yes except for certain data types. It can't compare text, ntext, image, cursor, xml and noncomparable common language runtime (CLR) user-defined types, according to the SQL Server Documentation


#3

So it is a Yes to which one :slightly_smiling_face:
Over all of the columns in the source table or only the columns in the select statement?

Thanks Joseph!


#4

From the link I posted to the Docs:
*
Specifies that the computation is over all the columns of the table. So

SELECT BINARY_CHECKSUM(*) FROM dbo.MyTable;

returns a checksum for all comparable columns, Whereas

SELECT BINARY_CHECKSUM(MyFirstCol, MySecondCol) FROM dbo.MyTable; 

would create a checksum for just the listed columns.


#5

ahh!! of course. wow had a long day was staring at my screen for too long.

Thanks Joseph!