I have this user-defined type that I would like to add a primary key or index to:
IF NOT EXISTS (
SELECT *
FROM sys.types st
JOIN sys.schemas ss
ON
Why not this?
CREATE TYPE [dbo].[DistCritGroupData] AS TABLE
(
[DistCritTypeId] [int] NOT NULL PRIMARY KEY CLUSTERED,
[ItemAction] [int] NOT NULL,
[ObjectId] [int] NOT NULL,
[OperatorType] [int] NOT NULL
);
or
CREATE TYPE [dbo].[DistCritGroupData] AS TABLE
(
[DistCritTypeId] [int] NOT NULL,
[ItemAction] [int] NOT NULL,
[ObjectId] [int] NOT NULL,
[OperatorType] [int] NOT NULL,
PRIMARY KEY CLUSTERED ([DistCritTypeId] ASC)
);
CREATE TYPE does not allow naming of contraints. Like table variables.