sql server - Inserting distinct value in one column and repeated value in other -
I have a database table with only 2 columns: TaskID & amp; Email When a user clicks on a button, he inserts a value in the table. I have written a stored procedure:
proc spTaskPerformed @TaskId int, @mail varchar (100) Insert into TblTaskPerformed values (@ TaskID, @ Email) end But I want to add only when TaskId distict. If I use the distict keyword for TaskId for a particular email, it allows me to include the same workcard, even if the email is changed . help.
If you want the pairs to be unique, you should have a unique force on prices:
create tblTaskPerformed (task id, email) at tblTaskPerformed_TaskId_Email; This will prevent duplicates in the table.
If you do not want the stored procedure to generate an error, then you try / hold statement to catch such errors.
Comments
Post a Comment