る | |
CHECKSUM | 伎碁煙 煙 |
CHECKSUM_AGG | 蠏碁9 伎螳 蟆曙 |
BINARY_CHECKSUM | ROW 覲蟆曙 蟆 |
HASHBYTES | れ煙 伎螳 |
--2000 SELECT BINARY_CHECKSUM('aa','AA','Arjan') ----------- 4225134 SELECT BINARY_CHECKSUM('BQ','AA','Arjan') ----------- 4225134 --2005 SELECT BINARY_CHECKSUM('aa','AA','Arjan') ----------- 4225134 SELECT BINARY_CHECKSUM('BQ','AA','Arjan') ----------- 4356206
use tempdb go create table item ( item_seq int , item_code nvarchar(400) , item_name nvarchar(2000) ); create index nix_item_code on item(item_code);
use tempdb go create table item2 ( item_seq int , item_code nvarchar(400) , item_name nvarchar(2000) , item_code_hash int ); create index nix_item_code on item2(item_code_hash); insert item2 values(1, 'A0001-1111', 'GCS-BSDEF-ASDFF, 伎蟲', checksum('A0001-1111')) select * from item2 where item_code_hash = checksum('A0001-1111') and item_code = 'A0001-1111' --checksum 蟆郁骸螳 狩る 覲伎レ 蠍 覓語 蠎 企蟆 伎 .
use tempdb go create table test ( id varchar(20) , pw varchar(20) , last_connect_dt datetime , check_sum int ); insert test select id , pw , last_connect_dt , binary_checksum(*) check_sum from ( select 'yasicom' id , '1234' pw , getdate() last_connect_dt ) t --螳煙 update test set last_connect_dt = getdate() where id = 'yasicom' select id , pw , last_connect_dt , check_sum old_hash --觜蟲 , binary_checksum(*) new_hash --觜蟲 from test where id = 'yasicom'
HashBytes ( '<algorithm>', { @input | 'input' } ) <algorithm>::= MD2 | MD4 | MD5 | SHA | SHA1
select hashbytes('md2', 'yasicom') , hashbytes('md4', 'yasicom') , hashbytes('md5', 'yasicom') , hashbytes('sha', 'yasicom') , hashbytes('sha1', 'yasicom')
CASE WHEN BINARY_CHECKSUM(@CustID)%5 = 0 THEN HashBytes('MD2', @CustID + @BirthDT + @PW) WHEN BINARY_CHECKSUM(@CustID)%5 = 1 THEN HashBytes('MD4', @BirthDT + @CustID + @PW) WHEN BINARY_CHECKSUM(@CustID)%5 = 2 THEN HashBytes('MD5', @PW + @CustID + @BirthDT) WHEN BINARY_CHECKSUM(@CustID)%5 = 3 THEN HashBytes('SHA', @CustID + @PW + @BirthDT) WHEN BINARY_CHECKSUM(@CustID)%5 = 4 THEN HashBytes('SHA1',@PW + @BirthDT + @CustID) ELSE HashBytes('MD5', @CustID + @BirthDT + @PW) END;