T-SQL Unique constraint locked the SQL server

Posted by PaN1C_Showt1Me on Stack Overflow See other posts from Stack Overflow or by PaN1C_Showt1Me
Published on 2010-06-09T15:59:22Z Indexed on 2010/06/09 16:02 UTC
Read the original article Hit count: 244

Filed under:
|
|
|
|

HI ! This is my table:

CREATE TABLE [ORG].[MyTable](   
    ..
    [my_column2] UNIQUEIDENTIFIER NOT NULL  CONSTRAINT FK_C1 REFERENCES ORG.MyTable2 (my_column2),  
    [my_column3] INT NOT NULL CONSTRAINT FK_C2 REFERENCES ORG.MyTable3 (my_column3)
    ..
    )

I've written this constraint to assure that combination my_column2 and my_column3 is always unique.

ALTER TABLE [ORG].[MyTable] ADD
 CONSTRAINT UQ_MyConstraint UNIQUE NONCLUSTERED
 (
    my_column2,
    my_column3
 )

But then suddenly.. The DB stopped responding.. there is a lock or something.. Do you have any idea why? What is bad with the constraint?

© Stack Overflow or respective owner

Related posts about tsql

Related posts about constraints