Sorry Peso found a solution I had the Deallocate statement in the wrong place in a nested cursor:Here is my correct code:SET NOCOUNT ongogoDECLARE @exists as varchar(300)DECLARE @result intDECLARE @failedstores as intDECLARE @date as varchar(100) DECLARE @sql as varchar(200)DECLARE @storeno as smallintDECLARE @tdate as char(3)DECLARE @errordescrip as varchar(100)DECLARE @rowc as intDECLARE storecursor2 CURSOR FOR Select store_no From retail2 Where store_no in (SELECT storenum FROM RetailChoiseStore)DECLARE daycursor CURSOR FOR Select tdate From adhoctaurex DECLARE @textdate as varchar(200)--drop and re-create items tablesDROP TABLE dbo.tmpisaleimportT CREATE TABLE dbo.tmpisaleimportT ([salesdata] [char] (56) [dayint] [int] )DROP TABLE dbo.itemsales_stores_input_errorTCREATE TABLE [itemsales_stores_input_errorT] ( [StoreNumber] [smallint] NULL , [Description] varchar(200), [DateInserted] [datetime] NULL CONSTRAINT [DF__itemsales__Date6I2__43F17C88] DEFAULT (getdate())) ON [PRIMARY]--drop and re-create offer tablesDROP TABLE dbo.tmpoffersaleimportT CREATE TABLE dbo.tmpoffersaleimportT ([salesdata] [varchar] (156) [dayint] [int] ) DROP TABLE dbo.offersales_stores_input_errorTCREATE TABLE dbo.[offersales_stores_input_errorT] ( [ErrorDescription] varchar(200) NULL , [DateInserted] [datetime] NULL CONSTRAINT [DF__offersales__Date6I2__43F17C88] DEFAULT (getdate())) ON [PRIMARY]OPEN daycursorFETCH NEXT FROM daycursor INTO @tdateWHILE @@FETCH_STATUS = 0 BEGINOPEN storecursor2FETCH NEXT FROM storecursor2 INTO @storenoWHILE @@FETCH_STATUS = 0 BEGIN SELECT @exists = '"' + 'DIR /B \\jy2003s\Data\isale'+ cast(@storeno as char(3))+'.'+@tdate+'"' EXEC @result = master..xp_cmdshell @exists , no_output -- if it does then bulk insert it into the tmpisaleimport table IF (@result = 0) begin select @date =''''+ '\\jy2003s\Data\isale'+ cast(@storeno as char(3))+'.'+@tdate+'''' Set @sql=' BULK INSERT [tmpisaleimportT] FROM '+@date Exec(@sql) IF @@rowcount = 0 Begin INSERT INTO itemsales_stores_input_errorT(StoreNumber, [Description]) VALUES (@storeno,'File does exist but has no data') End end ELSE -- if it doesn't plug it into the the error table which shows all failed store imports begin INSERT INTO itemsales_stores_input_errorT(StoreNumber, [Description]) VALUES (@storeno,'File does not exist') end FETCH NEXT FROM storecursor2 INTO @storenoENDCLOSE storecursor2 --find if the current offersale file exists in the itemsale folder select @exists = '"' + 'DIR /B\jy2003s\Data\OffrSale.'+@tdate+'"' EXEC @result = master..xp_cmdshell @exists -- if it does then bulk insert it into the tmpoffersaleimport table IF (@result = 0) begin select @date =''''+ '\\jy2003s\Data\OffrSale.'+@tdate+'''' Set @sql=' BULK INSERT [tmpoffersaleimportT] FROM '+@date Exec(@sql) end ELSE -- if it doesn't plug it into the the error table which shows all failed store imports begin set @errordescrip = 'The offer sale file did not exist for the date specified' INSERT INTO offersales_stores_input_errorT(ErrorDescription) VALUES (@errordescrip) set @rowc = @@rowcount endIF @rowc > 0 begin SELECT @textdate = 'The offersales file for ' +@tdate+ 'did not get imported please check offersales_stores_input_error table to check the time of failure' RAISERROR (@textdate,16,1) endFETCH NEXT FROM daycursor INTO @tdateENDDEALLOCATE storecursor2 CLOSE daycursorDEALLOCATE daycursor