How to drop unique key constraint/conditional unique key constraint in sql server?

sw
sw
170 Points
7 Posts

I'm try to delete following constraint but not to drop it:

 CREATE UNIQUE NONCLUSTERED INDEX UQ_MyTable_TypeKey ON [dbo].[MyTable]([TypeKey] ASC)
WHERE [TypeKey] <> 55555 AND [TypeKey] <> 75555)

Here is drop command:

ALTER TABLE [dbo].[MyTable] DROP CONSTRAINT UQ_MyTable_TypeKey

But getting error:

'UQ_MyTable_TypeKey' is not a constraint.
Could not drop constraint.
Views: 430
Total Answered: 3
Total Marked As Answer: 1
Posted On: 21-Apr-2024 22:19

Share:   fb twitter linkedin
Answers
sw
sw
170 Points
7 Posts
         

Also, tried as:

ALTER TABLE [dbo].[MyTable] DROP INDEX UQ_MyTable_TypeKey

But getting following error:

The operation 'ALTER TABLE DROP INDEX' is supported only with memory optimized tables.
Could not create constraint or index. See previous errors.
Posted On: 22-Apr-2024 00:17
dev3
dev3
154 Points
3 Posts
         

Try following command to drop key constraints:

DROP INDEX UQ_MyTable_TypeKey ON [dbo].[MyTable]
Posted On: 22-Apr-2024 01:18
sw
sw
170 Points
7 Posts
         

Thanks. Works for me.

Posted On: 22-Apr-2024 04:33
 Log In to Chat