Non unique key in MsSQL not visible

roxwal's profile image roxwal posted 3 years ago in Feature discussion Permalink

Can you add Non-unique key in index Tab for MS SQL Server tables:

You can use this Query to have the correct key status

select distinct
    s.name as SchemaName,
    DB_NAME() DBName,
    t.name as TableName,
       i.name as Keyname,
       i.type_desc,
       i.is_primary_key,
       i.is_unique,
    STUFF((
          SELECT ',' + tc.name
          FROM sys.columns tc
          inner join sys.index_columns ic on i.object_id=ic.object_id and i.index_id=ic.index_id
          WHERE ic.object_id=tc.object_id and ic.column_id=tc.column_id
          FOR XML PATH('')), 1, 1, '') as ColumnsName

from sys.schemas s
inner join sys.tables t   on s.schema_id=t.schema_id

inner join sys.indexes i  on t.object_id=i.object_id

where   t.name='<table name>'
order by t.name;

![image description]Difference not unque key

2 attachment(s):
  • HeidiSQL-problem
  • HeidiSQL-correct-key

Please login to leave a reply, or register at first.