Click here to Skip to main content
15,898,538 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
After executing below query am getting some error..

SQL
declare @emp varchar(50)
declare @oldfscode varchar(50)
declare @newfsname varchar(50)
declare @fstype varchar(50)
declare @parentcode varchar(50)
declare @areaname varchar(50)
declare @areacode varchar(50)
declare @parentype int
declare @grade varchar(50)
declare @qual varchar(50)
declare @add1 varchar(50)
declare @add2 varchar(50)
declare @add3 varchar(50)
declare @add4 varchar(50)
declare @pin char(50)
declare @phone char(50)
declare @email varchar(50)
declare @div char(50)
declare @newcode varchar(50)
declare @desg varchar(50)


declare toupdate cursor for 
select
empcode,fscode,fsname,type,parentcode,area,areacode,parenttype,grade,qual,add1,add2,add3,add4,pin,phone,email,div
,newcode,todes from r

open toupdate 
fetch next from  toupdate into
@emp,@oldfscode,@newfsname,@fstype,@parentcode,@areaname,@areacode,
@parentype,@grade,@qual,@add1,@add2,@add3,@add4,@pin,@phone,@email,
@div,@newcode,@desg
while @@FETCH_STATUS=0
begin


update Tbl_FS_Mst set C_Name='vacant - '+' '+@desg+' '+'('+@areaname+')',C_EmpNo='000000' where C_Code=@oldfscode
update tbl_fs_emp_rel set d_date_to='2015/03/03' where c_fs_code=@oldfscode
insert into Tbl_FS_Mst 
select @newcode,@newfsname,@fstype,@grade,@qual,@add1,@add2,@add3,@add4,@pin,@phone,
'','',@areacode,@parentcode,@emp,'','','','',0,@email,0,GETDATE(),GETDATE(),'admin',@parentype,@div
insert into tbl_fs_emp_rel select @newcode,@emp,GETDATE(),null,GETDATE()
update Tbl_Doc_Stock_Chem_Add_Mst set C_FsCode=@newcode where C_FsCode=@oldfscode
update Tbl_Cust_Div set c_fs_code=@newcode where c_fs_code=@oldfscode
update Tbl_STP set C_FS_Code=@newcode where C_FS_Code=@oldfscode
fetch next from  toupdate into
@emp,@oldfscode,@newfsname,@fstype,@parentcode,@areaname,@areacode,
@parentype,@grade,@qual,@add1,@add2,@add3,@add4,@pin,@phone,@email,
@div,@newcode,@desg

end
close toupdate
deallocate toupdate

Error will be shown like this
An error occurred while executing batch. Error message is: Exception of type 'System.OutOfMemoryException' was thrown.
Posted
Updated 4-Mar-15 17:42pm
v3
Comments
Wendelius 4-Mar-15 23:44pm    
When debugging the calling code, where do you get the exception? Most likely the exception isn't caused by the SQL code.

1 solution

Answer Here,
http://dba.stackexchange.com/questions/75326/management-studio-system-outofmemoryexception[^]

your executing 7 query statement in CURSOR.I think this is the reason you get this Error.Just Remove some Query from CURSOR and let me know what happend?
 
Share this answer
 
Comments
Member 11337367 5-Mar-15 0:30am    
I have removed last three update statement from the query..still result has not been changed..same error getting...
An error occurred while executing batch. Error message is: Error creating window handle.
King Fisher 5-Mar-15 1:05am    
try with only one Query

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900