We are no longer accepting contributions to Documentation. Please see our post on meta.
User Defined Table Types SQL Server 2008–SQL Server 2016
SQL Server 2000
SQL Server 2005
SQL Server 2008
SQL Server 2008 R2
SQL Server 2012
SQL Server 2014
SQL Server 2016
User defined table types (UDT for short) are data types that allows the user to define a table structure. User defined table types supports primary keys, unique constraints and default values.
This draft deletes the entire topic.
Examples
-
CREATE TYPE MyUniqueNamesType as TABLE ( FirstName varchar(10), LastName varchar(10), CreateDate datetime default GETDATE() PRIMARY KEY (FirstName,LastName) )
-
-
-
CREATE TYPE MyUniqueNamesType as TABLE ( FirstName varchar(10), LastName varchar(10), UNIQUE (FirstName,LastName) )
Note: constraints in user defined table types can not be named.
-
Please consider making a request to improve this example.
Remarks
UDTs have following restrictions -
- can not be used as a column in a table or a field in a structured user-defined types
- a non-clustered index cannot be created in a UDT unless the index is the result of creating a PRIMARY KEY or UNIQUE constraint on the UDT
- UDT definition CANNOT be modified after it is created
Still have a question about User Defined Table Types?
Ask Question
Sign up or log in
Save edit as a guest
Join Stack Overflow
Using Google
Using Facebook
Using Email and Password
We recognize you from another Stack Exchange Network site!
Join and Save Draftlang-sql