0

I'm running the following command in my DB:

CREATE UNIQUE INDEX [UK_NAME1] ON [TABLE1] ([COLUMN1] ASC);

Now, I'm running the following query:

SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS

And yet I can't find my unique index listed in there.

Am I using the wrong query? What other issue could there be?

1

Use this syntax, which also allows you to name the constraint:

ALTER TABLE Persons ADD CONSTRAINT UQ_PersonID UNIQUE (P_Id,LastName)
0

I used the wrong command to create the unique index. I should have used:

ALTER TABLE [TABLE1] ADD UNIQUE ([COLUMN1])

The only downside is that I can't name it on my own... but its a random name anyway.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.