0

I have two table as given below. Questions

  Questionid     Question
    1            Question1
    2            Question2
    3            Question3
    4            Question5
    5            Question8
    6            Question4

Answers

AnsID   AnsText Questionid
1   Ans1    1
2   Ans 2   1
3   Ans 3   1
4   Ans 4   1
5   Ans 8   2
6   Ans 5   2
7   Ans 6   2
8   Ans 7   2
9   Ans 9   3
10  Ans 15  3
11  Ans 14  3
12  Ans 13  3
13  Ans 12  4
14  Ans 11  4

Now want to Insert multiple question with multiple answers in sql server using User-Defined Table Types.

I have create a type for question table.

CREATE TYPE [dbo].[Questions] AS TABLE(
    [Questionid] [int] NULL,
    [Question] [nvarchar](max) NULL
)

And insert multiple question separately. But I want to insert multiple questions with multiple answer using User-Defined Table Types.

would you help me.

Zohar Peled
  • 79,642
  • 10
  • 69
  • 121
  • Possible duplicate of [Fastest way to perform nested bulk inserts with scope\_identity() usage?](http://stackoverflow.com/questions/34826450/fastest-way-to-perform-nested-bulk-inserts-with-scope-identity-usage) – Zohar Peled Mar 24 '17 at 07:29
  • it is easy.suppose you were to put question details and their answer in single table then what would be your design and how will you identify it ? – KumarHarsh Mar 24 '17 at 08:13
  • Then sorry.guess last line is not clear.can you show data,how you want to arrange it ?(But I want to insert multiple questions with multiple answer using User-Defined Table Types.) – KumarHarsh Mar 24 '17 at 10:03

0 Answers0