Link to home
Start Free TrialLog in
Avatar of GPSPOW
GPSPOWFlag for United States of America

asked on

Error running SQL stored procedure

I am trying to run a stored procedure that checks for the existence of a temp. table, deletes it if it exists and then recreates it.  Then it appends records from an existing sql table.  Lastly, it displays the table.  I am getting an error:

Msg 213, Level 16, State 1, Procedure sp_DAILY_Roll_Forward, Line 12
Column name or number of supplied values does not match table definition.


I have checked and rechecked the code and the table definitions and cannot find an error.  

Please take a look at the following code and let me know what I am missing.

USE [livedb]
GO
/****** Object:  StoredProcedure [dbo].[sp_DAILY_Roll_Forward]    Script Date: 06/26/2015 17:29:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[sp_DAILY_Roll_Forward] 
	As
if OBJECT_ID(N'tempdb..#RollFwd') is not null
begin
	drop table #RollFwd
end
Create table #RollFwd(
      [AccountNumber] varchar (15)
      ,CAmt numeric(15,2)
      ,[VisitID] varchar (15)
      );
insert into #RollFwd 
SELECT  [AccountNumber] 
      ,sum([CMBal]) as CAmt
      ,[VisitID]
      
  FROM [livedb].[dbo].[tbl_DAILY_ATB_PDBAL]
  where VisitID is not null and SUBSTRING(AccountNumber,1,1)<>'B' and AccountNumber not in ('A00000221516','A0000222086','A00000272018') 
  group by [AccountNumber],[VisitID]

Open in new window


select *
From #RollFwd

thanks

Glen
ASKER CERTIFIED SOLUTION
Avatar of dsacker
dsacker
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of GPSPOW

ASKER

Thanks