Actually it is not the insert statements.  SQL is using @cfid literally
instead of as a variable.  Does anyone know how to do this?

Joshua Tipton

-----Original Message-----
From: Joshua Tipton [mailto:[EMAIL PROTECTED]]
Sent: Monday, April 15, 2002 2:58 PM
To: CF-Talk
Subject: Stored Proc Problems


I am receiving an error that column name or number of supplied values does
not match table definition.  Something is up with my insert statements or
stored procs do not like dynamic table names.




Please help I know this is OT



CREATE PROCEDURE sp_missingcursor
@cfid nvarchar(50)
as

if exists (select * from sysobjects where id = object_id(N'[dbo].[@cfid]')
and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[@cfid]

CREATE TABLE [dbo].[@cfid] (
 [rr] [char] (2) NULL ,
 [memmonth] [varchar] (20) NULL ,
 [memyear] [char] (1) NULL ,
 [intcost1] [numeric](18, 0) NULL ,
 [extcost1] [numeric](18, 0) NULL
) ON [PRIMARY]

set nocount on

declare @rr char(2), @memmonth nvarchar(20), @memyear char(1), @intcost1
numeric, @extcost1 numeric

declare dispo_cursor CURSOR for

SELECT region, memomonth, memoyear,
 SUM(CASE WHEN SLIC NOT LIKE '88%' THEN cost ELSE 0 END) AS INTCOST,
 SUM(CASE WHEN SLIC LIKE '88%' THEN cost ELSE 0 END) AS exTCOST
FROM  dbo.CTMCORPAPP
WHERE region in ('00', '02', '03', '04', '05', '06', '07', '08', '09', '10',
'22') and [desc] Like '%Missing%'
GROUP BY memoyear,  memomonth, region

open dispo_cursor

  fetch next from dispo_cursor into @rr, @memmonth, @memyear, @intcost1,
@extcost1

insert into [dbo].[@cfid]
select @rr, @memmonth, @memyear, @intcost1, @extcost1

    while @@fetch_status = 0

      begin
 fetch next from dispo_cursor into @rr, @memmonth, @memyear, @intcost1,
@extcost1

insert into [dbo].[@cfid]
select @rr, @memmonth, @memyear, @intcost1, @extcost1

end

close dispo_cursor
deallocate dispo_cursor



______________________________________________________________________
Get the mailserver that powers this list at http://www.coolfusion.com
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to