I have table with articles and there is around 150.000 of records, in that table开发者_运维问答 I have column name which is type of varchar(45). Now I want to make index, constraints or trigger on that table which will keep column name unique at left of 35 character of same column.
What will be proper way to do that, I am afraid that I am going to lose performance of this large table If I use wrong method.
Create a computed column:
alter table YourTable add left35 as substring(col1, 1, 35)
Then you can create a unique index on that column:
create unique index IX_YourTable_left35 on YourTable(left35)
That will enfore the uniqueness of the left 35 characters of col1
.
精彩评论