Need to create unique key on ref_number column in [purchase_order] table,
while use below
CREATE UNIQUE NONCLUSTERED INDEX [idx_unique_PO] ON [dbo].[purchase_order]
(
[ref_number] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [psPurchase_order]([id])
getting error,
Column 'id' is partitioning column of the index 'idx_unique_PO'. Partition columns for a unique index must be a subset of the index key.
So i created Partion-key index, this one created but this still allow duplicate
CREATE UNIQUE NONCLUSTERED INDEX [IX_Unique_purchase_order_partic] ON [purchase_order]
(
[ref_number] ASC,
id
) ON [psPurchase_order](id)