Inserting sproc resultset into a table

  • Hi,

    I have a stored procedure that returns a resultset. I want to insert this resultset into another table. I tried this,

    INSERT INTO table1 EXEC proc_storedproc1

    It returns an error saying the columns does not match. I think it is trying to insert the value 'EXEC proc_storedproc1' into table1. Can we do inserts like this? If yes, can you tell me what is the correct syntax.

    Thanks.

  • Compare resultset of EXEC proc_storedproc1  to column definitions for table1.

    They must be different.

    _____________
    Code for TallyGenerator

  • I checked it. Its the same.

  • Maybe best to check again.

    Your syntax is fine, but the result returned does not match the table you're trying to insert into.

    They aren't the same.

    If you still can't find the difference, can you post the table definition, and a sample row of what the proc returns?

    /Kenneth

  • I checked it. Its not the same. Sorry.

    The table I am working on inside the sproc and the table I am trying to insert into have the same definition. But I missed a column in the sproc select statement.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply