I have a table voucher_master. I want to make composite unique key which satisfies the below condition
voucher_type voucher_sub_type date Abbreviation
INV DOM 1/1/2000 ID allowed
INV DOM 15/1/2000 ID allowed
INV INT 1/1/2000 ID not allowed
INV INT 15/3/2012 ID not allowed
If a particular abbreviation is created for voucher_type and voucher_sub_type then the same abbreviation cannot be created for any combination of voucher_type and voucher_sub_type.
However, if the abbreviation is created for a voucher_type and voucher_sub_type then the same abbreviation can be created with a difference of date for the same combination for which it was originally made. The same abbreviation cannot be created for any other combination.
How to do this in sql server?
Thanks all,
I solved the problem with stored procedure and checked the required condition during insert and update