Surrogate Key | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Surrogate Key

Hi:<br /><br />What in SQL Server is a SURROGATE KEY? Is it different from a the normal PRIMARY KEY. If yes, then how? And if not, then what is the difference between the two.<br /><br />Thanx.[<img src=’/community/emoticons/emotion-1.gif’ alt=’:)‘ />]<br />
A surrogate key is a meaningless value which is unique for each row. In SQL Server this would be an identity field or a uniqueidentifier field A primary key is a combination of columns which are unique for all rows in a table So a surrogate key is normally a primary key, but the other way does not necessarily hold true Cheers
Twan
Adding to what Twan has said…. if your table has large no. of columns which together form a primary key, its advisable to have a surrogate key which may be used as refernece in foreign keys of other tables. Gaurav
Moderator
Man thrives, oddly enough, only in the presence of a challenging environment- L. Ron Hubbard

In most cases using an identity property is fine for surrogate keys. Immediately after inserting a row, if you want to refer the new value use Scope_identity. _________
Satya SKJ
Moderator
SQL-Server-Performance.Com

]]>