Example
Employe Table
Id Primary key
Name varchar,
Phone int,
Department,
Should I give unique key to avoid duplicate entry?
Like on phone number
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
Gajendra JangidRank #157 · 14.9K reputationPosted Jan 17, 2019, 10:17 PM EST
Karan Thakkar186 reputationPosted Jan 18, 2019, 8:27 PM EST
Salman BegRank #284 · 8.8K reputationPosted Jan 22, 2019, 4:57 AM EST
Puneet KankarRank #446 · 5.6K reputationPosted Jan 22, 2019, 5:11 AM EST
try { } catch(Exception ex) { if(ex.GetBaseException().GetType() == typeof(SqlException)) { //Violation of primary key/Unique constraint can be handled here. Also you may //check if Exception Message contains the constraint Name } }Kalyani ShevaleRank #1,111 · 1.7K reputationPosted Jan 22, 2019, 5:32 AM EST
Shahriar NikkhahRank #248 · 10.1K reputationPosted Jan 27, 2019, 2:32 PM EST
Good luck