0

I have a type like this

CREATE TYPE mytabletype AS TABLE 
(
     a int NOT NULL PRIMARY KEY,
     b int NOT NULL,
     c int NOT NULL                                
)

I want to create either a tabletype or a table like this

create type mytabletype2 as table
(
     a int not null primary key,
     b mytabletype
)

But SQL Server 2016 does not like the line b mytabletype - any workaround or tricks to overcome that?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
jhon.smith
  • 1,963
  • 6
  • 30
  • 56
  • 4
    SQL Server does not support nested table types. You could instead use XML or JSON. – Dan Guzman Mar 12 '19 at 02:36
  • Look at this: [JSON data in SQL Server](https://learn.microsoft.com/en-us/sql/relational-databases/json/json-data-sql-server?view=sql-server-2017), you can store any type of object in JSON format. – Hasan Mahmood Mar 12 '19 at 02:51
  • In a RDBMS this should be a related side table. XML or JSON might be a workaround, but will be a bad choice, if you want to use data **within** this "type" regularly... You might read [this related question](https://stackoverflow.com/q/43494824/5089204) – Shnugo Mar 12 '19 at 09:12

0 Answers0