반응형

/**********************************************************************************************
-- Title : [2k5] BINARY_CHECKSUM을 활용한 행 수정내용 검색
-- Reference : dbrang.com
-- Key word : 체크섬 binary_checksum 해쉬 hash
**********************************************************************************************/
-- binary_checksum과 checksum_agg 사용법하고 구분이 좀 모호하다..
-- 머리가 점점 죽는다..ㅠㅠ
use tempdb;
go

drop table ttt;
go

create table ttt
( a int not null identity
, b int not null
, c nvarchar(5) not null
, bin_chksum int
)
go

declare @i int;
set @i = 1;
while (@i <= 100)
begin
    insert into ttt values (@i,'babo',0);
    set @i = @i + 1;
end;
go

update ttt
set bin_chksum = binary_checksum(*);
go

select * from ttt;
go

update ttt
set c = 'wony'
where a < 10;
go

select a,b,c, bin_chksum "1th_hash", binary_checksum(*) "2nd_hash"
from ttt;
go

update ttt
set c = 'hwany', b = b + 100
where a < 15 and a > 11;
go

select a,b,c, bin_chksum "1th_hash", binary_checksum(*) "2nd_hash"
from ttt;
go

반응형

+ Recent posts