DATETIME SELECT SELECT INTO DATE PAD STRING DYNAMIC SQL CURSOR MONEY FORMAT PERCENT STORED PROCEDURE SQL SERVER AGENT JOB OPTIMIZATION WHILE LOOP OVER PARTITION BY UPDATE
 
 
SITE SEARCH SQLUSA.com VIDEOS
 
 
SQL E/BOOKS   WORLD, USA & SQL NEWS   FORMAT
SCRIPTS SQL 2005 SQL 2008 ARTICLES
How to apply checksum?

Checksum calculates a "fingerprint" of the supplied string argument. It is used for data verification. It returns INT. Here are some examples:

select CHECKSUM('Joanna Smith')

-- 1017174263

 

select CHECKSUM('Joanna Smitg')

 

-- 1017174262

 

select CHECKSUM('Joanna Smith lives in New York City')

GO

-- 167919681

 

-- Random number generation in conjunction with NEWID() function

select CHECKSUM(newid())

GO 3

-- -123549627

-- 15673588

-- 1263227242

 

------------

-- Generating random phone numbers - data obfuscation

------------

DECLARE @Phone char(10) = '2123458200'

DECLARE @NewPhone char(10) = left(@Phone,3)+

        LEFT(convert(varchar,ABS(CHECKSUM(newid()))+'0000000'),7)

SELECT @Phone, @NewPhone

GO 5

-- 2123458200     2121631287

-- 2123458200     2121470137

-- 2123458200     2121441560

-- 2123458200     2122004110

-- 2123458200     2121007063

------------

 

Exam Prep 70-461
SQL 2016 DESIGN & PROGRAMMING
 
 
 
DATETIME SELECT SELECT INTO DATE PAD STRING DYNAMIC SQL CURSOR MONEY FORMAT PERCENT STORED PROCEDURE SQL SERVER AGENT JOB OPTIMIZATION WHILE LOOP OVER PARTITION BY UPDATE