I would like to better understand the differences for checking uniqueness in a record before an INSERT between using CHECKSUM (with unique constraints) versus self-referencing table statement like the one below. What scenarios would pose one option to be the best choice over the other, and for what reasons?
Requirement: Each set of columns need to be unique from every record in the table, which is why I put this statement together; to check for all columns in one call to the database.
INSERT INTO tblTable
(Column1, Column2, Column3, Column4, Column5, Column6)
SELECT
@Column1, @Column2, @Column3, @Column4, @Column5, @Column6
WHERE NOT EXISTS
(SELECT DISTINCT
t1.Column1,
t1.Column2,
t2.Column3,
t2.Column4,
t3.Column5,
t3.Column6
FROM tblTable t1
JOIN tblTable t2 ON (t1.UID = t2.UID)
JOIN tblTable t3 ON (t1.UID = t3.UID)
WHERE
t1.Column1 = @Column1 and
t1.Column2 = @Column2 and
t2.Column3 = @Column3 and
t2.Column4 = @Column4 and
t3.Column5 = @Column5 and
t3.Column6 = @Column6)