How to find out whether a table has some unique columns

前端 未结 5 2016
太阳男子
太阳男子 2020-12-06 06:25

I use MS SQL Server.

Ive been handed some large tables with no constrains on them, no keys no nothing.

I know some of the columns have unique values. Is ther

5条回答
  •  -上瘾入骨i
    2020-12-06 06:41

    What about simple one line of code:

    CREATE UNIQUE INDEX index_name ON table_name (column_name);
    

    If the index is created then your column_name has only unique values. If there are dupes in your column_name, you will get an error message.

提交回复
热议问题