How to use select into statement?
I want to insert records from Table1 and Table2 into Table3 and my Table3
has Two columns:
studentId
subjectId
And I want to insert these 2 values from Table1(contains 1000 student
Id's) and From Table2(contains 5 subjects). To achieve that I have used
following query but it gave me error
Query:
INSERT INTO StudentSubject(studentId,subjectId)
SELECT studentId FROM Table1 UNION SELECT subjectId FROM Table2
But I got this error message:
Msg 120, Level 15, State 1, Line 1 The select list for the INSERT
statement contains fewer items than the insert list. The number of SELECT
values must match the number of INSERT columns.
No comments:
Post a Comment