Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert Error

Status
Not open for further replies.
Mar 20, 2009
102
US
Could someone "please" tell me what I am doing wrong in the below code to get this error:

Insert Error: Column name or number of supplied values does not match table definition.


create table #Results2 (taxablessficawages money, taxablemedicalwages money)

insert into #Results2 (taxablessficawages, taxablemedicalwages)
exec udsp_get941ReconReport @Qtr, @Year
SET @Qtr = case
when @qtr = 1 then 4
when @qtr = 2 then 1
when @qtr = 3 then 2
when @qtr = 4 then 3
END
SET @Year = case
when @qtr = 4 then @Year-1
else @Year
End


Select
ISNULL(r2.TaxableSSFICAWages,0) TaxableFICAWages,
ISNULL(r2.TaxableMedicalWages,0) TaxableMedWages,
ISNULL(r.TaxableSSFICAWages,0) TaxableSSFICAWages,
ISNULL(r.TaxableMedicalWages,0) TaxableMedicalWages,
ISNULL(r.SSActual,0) SSActual,
ISNULL(r.SSMedActual,0) SSMedActual

from #Results r
INNER JOIN #Results2 r2 ON 1=1

 
Probably this:

Code:
create table #Results2 (taxablessficawages money, taxablemedicalwages money)

insert into #Results2 (taxablessficawages, taxablemedicalwages)   
exec udsp_get941ReconReport @Qtr, @Year

When you use insert/exec, the table you insert in to MUST have the exact same columns and data types as the recordset returned by the stored procedure.

Run this....

[tt][blue]exec udsp_get941ReconReport 1, 2009[/blue][/tt]

How many columns are returned? Whatever is returned from the stored procedure must exist in your #Results2 table. The columns must match.

Make sense?

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top