BUG: INSERT EXECUTE Statement May Fail with Error 213

ID: Q171875


The information in this article applies to:

BUG #: 17040 (NT: 6.5)

SYMPTOMS

If you use the INSERT EXECUTE statement and specify a column list to insert into a table with a timestamp column, and the stored procedure called does not return a value for the timestamp column in the result set, the INSERT statement may fail with following error:

Msg 213, Level 16, State 1
Insert error: column name or number of supplied values does not match
table definition.

The following scenario demonstrates this problem:

   CREATE TABLE t1 (
      test1 int NOT NULL ,
      test2 timestamp NOT NULL ,
      )
   GO

   CREATE TABLE t2 (
      test1 int NOT NULL ,
      test2 timestamp NOT NULL ,
      )
   GO

   CREATE PROCEDURE sp_1 AS
       select test1 from t1
   GO

   insert into t1 values (1,null)
   insert into t1 values (2,null)
   insert into t1 values (3,null)
   GO

   insert into t2 (test1) exec sp_1
   GO 

The INSERT fails with the error message described above.


WORKAROUND

To work around this problem, modify the stored procedure to return a NULL value for the timestamp column, as in the following example:


   CREATE PROCEDURE sp_1 AS
   select test1, null from t1
   GO 


STATUS

Microsoft has confirmed this to be a problem in Microsoft SQL Server version 6.5. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

Additional query words: Transact-SQL transql tsql


Keywords          : kbusage SSrvTran_SQL kbbug6.50 
Version           : 6.5
Platform          : WINDOWS 
Issue type        : kbbug 

Last Reviewed: April 19, 1999