BUG: Insert From Subquery Returns Error Message 213 "Insert Error.." (284141)



The information in this article applies to:

  • Microsoft SQL Server 7.0

This article was previously published under Q284141
BUG #: 101144 (SQLBUG_70)

SYMPTOMS

The second INSERT in the script shown in the "More Information" section attempts to insert values into a table from a subquery. When you run the script, this error message occurs:
Server: Msg 213, Level 16, State 3, Line 2
Insert Error: Column name or number of supplied values does not match table definition.

WORKAROUND

To work around this problem, you can change the INSERT statement to either:
  • insert x (b,c) select b,c from y
    						
    -or-
  • insert x (b,c) select b,c from (select b,c from y) z
    						

STATUS

Microsoft has confirmed this to be a problem in SQL Server 7.0.

MORE INFORMATION

To reproduce this problem, run this script:
use tempdb
go
create table x (b int, c int)
create table y (b int, c int)
go
insert y (b,c) values (1,1)
insert x (b,c) select * from (select b,c from y) z
go
drop table x
drop table y
go
				

Modification Type:MajorLast Reviewed:10/16/2002
Keywords:kbBug kbDSupport KB284141