|
-
Apr 26th, 2011, 09:06 AM
#1
Thread Starter
Frenzied Member
SQL SERVER 2008 How to enforce Integrity Scenario
I have set up the unique index below
CREATE UNIQUE NONCLUSTERED INDEX [IX_Products__supplier_id__product_code__active__default] ON [Live].[tbl_Products]
(
[supplier_id] ASC,
[Product_code] ASC,
[active] ASC,
[product_code_default] 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 [PRIMARY]
GO
This allows me to stop multiple product codes from the same supplier being entered as the default and active.
However I really only want to enforce this on active = true, I dont really care if there are multiples in there which are marked as active = false. I have come across this problem when trying to update a product to being in active and the index wont let me because there is already an identical inactive record.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|