Hi...........
I want to know about candidate key and alternate key in SQL Server. Please explain anyone candidate key and alternate key with an example and also explain difference between them ?
Thanks........
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
SenthilkumarRank #387 · 6.5K reputationPosted Mar 12, 2012, 7:11 PM EDT
candidate key- A candidate key is one that can identify each row of a table uniquely. Generally a candidate key becomes the primary key of the table.
alternate keys- Any of the candidate keys that is not part of the primary key is called an alternate key.
When you talk about the alternative key, the column may not be primary key but still it is the unique key of the column. Typically identity column in the table is alternative key.
ID INT IDENTITY(1,1)
In the above attribute you have not defined as primary key, but still it will enforce the uniqueness of the column.
Jignesh TrivediRank #16 · 50.3K reputationPosted Mar 12, 2012, 8:26 PM EDT
A Candidate Key is any column or a combination of columns in table that could be qualify as unique key in database.
multiple Candidate Keys on one table is also possible.
Candidate keys that follow all the three rules -
1) Not Null
2) Unique Value in Table
3) Static
If table have more then one candidate keys,the remining candidate keys column(s) which is not part of primary key is called Alternate Key
one differance, you can find in defination.
Candidate key use in primary key so it can mot be null but alternate key may be null in certain condition.
hopet this help.
Vikash Sinha97 reputationPosted May 5, 2013, 9:20 PM EDT
For reffrence :http://www.thedevheaven.com/2013/05/candidate-key-vs-primary-key-vs.html