0

hi,
how to create nested table in sql server for example
employee table contains 3 column
id
name
address

where name should contain 3 sub columns like
firstname
middlename
lastname

how can i get this one help me plz

5
Contributors
5
Replies
7
Views
6 Years
Discussion Span
Last Post by adam_k
0

The short answer is you can't. Oracle has nested tables, but MS SQL server doesn't.
If you describe why you want this / what are you trying to achieve perhaps we can find you with an alternative (like 6 columns in your employee table that you concatenate in a view or a second table that will hold your name data).

Edited by adam_k: n/a

0

That's only in Analysis Services. If you want a general relational table structure (as in you can use it for OLTP), SQL Server doesn't support nested tables.

0

Create a table with "id", "firstname", "middlename", "lastname", "address"

And select them into 1 field... closest I think you are going to get to what you seek...

Alternatively you can try different select statements or tricks to display in different ways... but I dont believe the nested tables are gonne fly

0

Depending on the need/application you could use a varchar field that would separate "fields" with a specific char and then either use charindex or split into an array from the front end or store XML into the field or ... , but not of these are a nested table.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.