I need to run a routine to find all disabled unique keys in SQL Server, or at least know if a UK exists and is disabled.
IF (OBJECT_ID('UK_NAME'UQ') IS NOT NULL)
BEGIN
PRINT('EXISTS')
END
ELSE
BEGIN
PRINT('DOESNT EXISTS')
END
This code doesn't work if a UK is disabled, as the system can't find the UK. Is there a table that I can find all UK even if it is disabled?
Maybe you can use :
Select * From sys.indexes