0
CREATE TYPE DBO.ADDRESSTYPE AS TABLE
(
    LocationName VARCHAR(50), 
    PIN NUMERIC
); 

CREATE TABLE mycustomer 
(
    cust_id NUMERIC, 
    name varchar(50), 
    current_address ADDRESSTYPE
);

Can someone help to create table with user defined dataype in sql server?

Zohar Peled
  • 79,642
  • 10
  • 69
  • 121
Yogi
  • 1
  • 2
  • 1
    Though the duplicate question asks about two user defined table types the same rules apply to normal tables as well. – Zohar Peled Dec 06 '18 at 08:23

1 Answers1

2

SQL Server doesn't support "nested" tables, so no, you cannot do this. Consider creating a separate (normal) Addresses table and then using foreign keys as appropriate between Addresses and Customers.

Damien_The_Unbeliever
  • 234,701
  • 27
  • 340
  • 448