sql server create constraint

Solutions on MaxInterview for sql server create constraint by the best coders in the world

showing results for - "sql server create constraint"
Davide
07 Aug 2018
1ALTER TABLE my_table ALTER COLUMN [Name] VARCHAR(50) NOT NULL;
2ALTER TABLE my_table ADD CONSTRAINT UQ__Constrai UNIQUE (ID);
3ALTER TABLE my_table ADD PRIMARY KEY (ID);
4-- Get constraints names
5SELECT CONSTRAINT_NAME,
6     TABLE_SCHEMA ,
7     TABLE_NAME,
8     CONSTRAINT_TYPE
9     FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS
10   WHERE TABLE_NAME='my_table';
11ALTER TABLE my_table DROP CONSTRAINT PK__Constrai__xxxxx;