BUG: INSERT EXECUTE Statement May Fail with Error 213

Last reviewed: July 30, 1997
Article ID: Q171875
The information in this article applies to:
  • Microsoft SQL Server, version 6.5
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 : kbbug6.50 SSrvTran_SQL kbusage
Version : 6.5
Platform : WINDOWS
Issue type : kbbug
Solution Type : kbworkaround


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 30, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.