I have a table like below
ID Value
----------
1 A
2 B
3 C
3 C
4 A
4 D
5 A
5 C
5 D
I want a query or stored procedure that will identify If there is already a combination exist if I try to insert the same kind of value combination. eg: If I am trying to insert
6 A
6 D
will let me know that there is already the same combination exist with id 4. is it possible in MSSQL?
Few Comments: When I am trying to insert the new values the Id will be new, so we can't have a search on the table for duplicate rows with id, value combination. I need a way to search for the duplicate values with the same id value combination.
In the above sample when I am trying to insert
6 A
6 D
It will go and search in the table if there is any rows exist for values with A and D having the same ID in the above table there is an ID 4 so it should let me know that there is a duplicate entry when I try to insert this.