How Do I Kill Off An Old Cursor In Memory

Apr 18, 2006

there is a sproc with cursors . occasionally the sproc fails before the cursors can be deallocated. when i try to deallocate the cursor manually im told it doesnt exist, even though i can clearly see it when i go to :



select * from sys.dm_exec_cursors(0)



how do i kill off my cursor that isnt being used??

View 1 Replies


ADVERTISEMENT

Cursor In Sproc To Kill Spids Loops Forever

Mar 20, 2000

I need a stored proc to kill spids, but the following sproc loops infinitely with the same [correct] spid being printed out. What am I doing wrong?

The select statement, when I execute it via the query grid, returns the correct and finite number of spids.

Any help greatly appreciated.
Judith


CREATE PROCEDURE rasp_KillDBProcess
@dbname varchar(128)
AS
declare @KillSpid smallint
declare @SQL varchar(1000)
--
declare DBCursor cursor Forward_only for SELECT distinct l.spid
FROM master.dbo.syslocks l INNER JOIN
master.dbo.sysdatabases d ON l.dbid = d.dbid
WHERE (d.name = N'coj_pcisdata')
open DBCursor
--
Fetch next from DBCursor into @Killspid
--
While (@@Fetch_status <> -1)
Begin
If (@@Fetch_status <> -2)
begin
print 'spid = ' + cast(@killspid as varchar(12))
--exec ('kill ' + @killspid)

end
--
end
Fetch next from DBCursor into @Killspid
--
close dbcursor
deallocate dbcursor
print 'end'

return

View 1 Replies View Related

You Cannot Use KILL To Kill Your Own Process. Why?

Mar 24, 1999

I'm trying to kill a bunch of processes in SQL 6.5 and I can't. I'm running the only machine with SQL tools installed on it (the server) and it won't let me kill them. I try the GUI screens and the Kill statement in ISQL_w. Is there any way around this?

I've stopped the SQL Server and rebooted the NT Server. Is there anyway I can get rid of these processes. They are locking some tables and keeping me from inserting data within my code. Very frustrating.

Thanks

View 2 Replies View Related

Transact SQL :: STATIC Defines A Cursor That Makes Temporary Copy Of Data To Be Used By Cursor

Aug 12, 2015

In MSDN file I read about static cursor

STATIC
Defines a cursor that makes a temporary copy of the data to be used by the cursor. All requests to the cursor are answered from this temporary table in
tempdb; therefore, modifications made to base tables are not reflected in the data returned by fetches made to this cursor, and this cursor does not allow modifications

It say's that modifications is not allowed in the static cursor. I have a  questions regarding that

Static Cursor
declare ll cursor global static
            for select  name, salary from ag
  open ll
             fetch from ll
 
              while @@FETCH_STATUS=0
               fetch from ll
                update ag set salary=200 where 1=1
 
   close ll
deallocate ll

In "AG" table, "SALARY" was 100 for all the entries. When I run the Cursor, it showed the salary value as "100" correctly.After the cursor was closed, I run the query select * from AG.But the result had updated to salary 200 as given in the cursor. file says  modifications is not allowed in the static cursor.But I am able to update the data using static cursor.

View 3 Replies View Related

Dynamic Cursor Versus Forward Only Cursor Gives Poor Performance

Jul 20, 2005

Hello,I have a test database with table A containing 10,000 rows and a tableB containing 100,000 rows. Rows in B are "children" of rows in A -each row in A has 10 related rows in B (ie. B has a foreign key to A).Using ODBC I am executing the following loop 10,000 times, expressedbelow in pseudo-code:"select * from A order by a_pk option (fast 1)""fetch from A result set""select * from B where where fk_to_a = 'xxx' order by b_pk option(fast 1)""fetch from B result set" repeated 10 timesIn the above psueod-code 'xxx' is the primary key of the current Arow. NOTE: it is not a mistake that we are repeatedly doing the Aquery and retrieving only the first row.When the queries use fast-forward-only cursors this takes about 2.5minutes. When the queries use dynamic cursors this takes about 1 hour.Does anyone know why the dynamic cursor is killing performance?Because of the SQL Server ODBC driver it is not possible to havenested/multiple fast-forward-only cursors, hence I need to exploreother alternatives.I can only assume that a different query plan is getting constructedfor the dynamic cursor case versus the fast forward only cursor, but Ihave no way of finding out what that query plan is.All help appreciated.Kevin

View 1 Replies View Related

Could Not Complete Cursor Operation Because The Set Options Have Changed Since The Cursor Was Declared.

Sep 20, 2007

I'm trying to implement a sp_MSforeachsp howvever when I call sp_MSforeach_worker
I get the following error can you please explain this problem to me so I can over come the issue.


Msg 16958, Level 16, State 3, Procedure sp_MSforeach_worker, Line 31

Could not complete cursor operation because the set options have changed since the cursor was declared.

Msg 16958, Level 16, State 3, Procedure sp_MSforeach_worker, Line 32

Could not complete cursor operation because the set options have changed since the cursor was declared.

Msg 16917, Level 16, State 1, Procedure sp_MSforeach_worker, Line 153

Cursor is not open.

here is the stored procedure:


Alter PROCEDURE [dbo].[sp_MSforeachsp]

@command1 nvarchar(2000)

, @replacechar nchar(1) = N'?'

, @command2 nvarchar(2000) = null

, @command3 nvarchar(2000) = null

, @whereand nvarchar(2000) = null

, @precommand nvarchar(2000) = null

, @postcommand nvarchar(2000) = null

AS

/* This procedure belongs in the "master" database so it is acessible to all databases */

/* This proc returns one or more rows for each stored procedure */

/* @precommand and @postcommand may be used to force a single result set via a temp table. */

declare @retval int

if (@precommand is not null) EXECUTE(@precommand)

/* Create the select */

EXECUTE(N'declare hCForEachTable cursor global for

SELECT QUOTENAME(SPECIFIC_SCHEMA)+''.''+QUOTENAME(ROUTINE_NAME)

FROM INFORMATION_SCHEMA.ROUTINES

WHERE ROUTINE_TYPE = ''PROCEDURE''

AND OBJECTPROPERTY(OBJECT_ID(QUOTENAME(SPECIFIC_SCHEMA)+''.''+QUOTENAME(ROUTINE_NAME)), ''IsMSShipped'') = 0 '

+ @whereand)

select @retval = @@error

if (@retval = 0)

EXECUTE @retval = [dbo].sp_MSforeach_worker @command1, @replacechar, @command2, @command3, 0

if (@retval = 0 and @postcommand is not null)

EXECUTE(@postcommand)

RETURN @retval



GO


example useage:


EXEC sp_MSforeachsp @command1="PRINT '?' GRANT EXECUTE ON ? TO [superuser]"

GO

View 7 Replies View Related

SQL In-Memory :: Table Memory Optimization Advisor Validation Passed But Cannot Migrate

Jul 13, 2015

I am looking to test this feature - and the "Transaction Performance Collector" has recommended me a table to port to In-Memory OLTP. 

I have now tried the "Table Memory Optimization Advisor" tool.

After a couple of tweaks to the table design - the tool is now passing validation but the tool is not allowing to progress to the next step:

Could it be down to not having enough memory? But would this not show in the advisor?

View 4 Replies View Related

Attempted To Read Or Write Protected Memory. This Is Often An Indication That Other Memory Is Corrupt. (Microsoft Visual Studio)

Sep 28, 2007

Hello. I have received the follwoing error upon an attempt to Browse the Cube. All other tabs are functional, including the Calculations tab. We are running Windows Server 2003 SP2 and SQL Server 2005 SP2. Any suggestions would be greatly appreciated!

**EDIT** - Have confirmed SP1 for VS2005 is installed both locally and on server, also.


Attempted to read or write protected memory. This is often an indication that other memory is corrupt. (Microsoft Visual Studio)

------------------------------
Program Location:

at Microsoft.Office.Interop.Owc11.PivotView.get_FieldSets()
at Microsoft.AnalysisServices.Controls.PivotTableFontAdjustor.TransformFonts(Font font)
at Microsoft.AnalysisServices.Browse.CubeBrowser.UpdatePivotTable(Boolean translate)
at Microsoft.AnalysisServices.Browse.CubeBrowser.UpdateAll(Boolean translate)
at Microsoft.AnalysisServices.Browse.CubeBrowser.InitialUpdate()
at Microsoft.AnalysisServices.Browse.CubeBrowser.SupportFunctionWhichCanFail(FunctionWhichCanFail function)

View 4 Replies View Related

AWE/Lock Page In Memory Drawbacks? Min/Max Settings, Memory Issues

Oct 11, 2007

I've been researching AWE to determine if we should enable this for our environment.

Currently we have a quad core box with 4 gb of RAM (VMware). OS: Windows 2003 std, SQL Server 2005 std. 3GB is not set but will be as soon as we can perform maintenance on the server.

I have read mixed feedback on AWE, either it works great or grinds you to a hault. I would assume that the grinding to a hault is due to not setting the min/max values correctly or not enabling the lock page in memory setting.

We only have one instance of SQL on the server and this box won't be used for anything else aside from hosting SQL services. We do plan on running SSRS off of this server as well.

1. Will running SSRS and enabling AWE cause me problems? Will I have to reduce the max setting by the SSRS memory usage or will it share and play nice?

2. How do I go about setting the Max value? Should it be less than the physical RAM in the box? Right now its set to the default of 214748364, even if I don't enable AWE should this default value be changed?

3. It seems that even at idle the SQL server holds a lot of memory and the page file grows. If I restart the process in the morning, memory usage in taskmon is at 600mb or so. By the end of the day, its up around 2gb. How can I track down whats causing this, should this even concern me?

4. The lock Page in memory setting worries me. Everything I've read on this seems to give a warning about serious OS and other program support degradation. In some cases to the point where they have to restore the settings on the server before they can bring it back up. What are your thoughts on this.

View 3 Replies View Related

Kill Won&#39;t Kill

Apr 25, 2001

I have a replication log reader SPID hanging.
When the logreader tries to run again, it fails
due to Error 14151 Replication log reader - task "blah" failed. Another log reader is replicating the database.

I do a sp_who2 on the database and identify the spid that is running
the logreader, from here I usually kill the spid and the log starts up again no problem. Now the spid WON"T DIE!!!
Any help would be appreciated.
Thanks
Susan

View 2 Replies View Related

Kill

Feb 4, 2008

Hi,

We are planing to write a script that execute frequently to kill processes that are running for more than 1 minute. Does anyone knows the logic to filter out system or other required SQL processes from this auto kill script


regards

Priv

View 8 Replies View Related

SQL In-Memory :: How To Reduce Memory Usage Without Killing Any Process

Aug 28, 2015

I have a Windows sever 2012 with sql server 2012 enterprise. Ram size is 22GB. Sometimes SQL sever takes 95% memory.My question, How to reduce memory size without killing any process because it's production server.So there are many background process is running. And,Is there any guides to learn why Memory is raise d so high and how to reduce it.

View 10 Replies View Related

Not Able To Kill The Process

Mar 27, 2001

Hi all,

I have SQL Server 7.0 with SP2 on it and I am not able to kill one of the SPID's who is running a SELECT Statement.
When I saw in the current activity in EM I see the STATUS as ROLLBACK, COMMAND as SELECT, APPLICATION as MS SQLEM-DATATOOLS, WAITTIME as 5375 and WAITTYPE as CXPACKET..

I also tried to reboot the machine of that particular SPID , but it still shows up in the Enterprise Manager.

Can anyone tell me how to kill this process and how to get around this Problem


Any Ideas,
Thanks in Advance
Venu

View 4 Replies View Related

Kill Process

Sep 4, 2001

Hi, there, do you know how to kill a process without restart SQL Server?

I tried Kill from SQL Query analyzer and Enterprise Manager, but it not work as before. Please advise, Thank you very much

Tony

View 1 Replies View Related

T-SQL Kill Command

Jul 24, 2000

BOL say to kill a process use (i.e. Kill 10).

I am trying to get the kill command to accept a variable

declare @aProcess smallint
set @aProcess = 30
kill @aProcess

On the above code I get the following syntax error.

Server: Msg 170, Level 15, State 1, Line 3
Line 3: Incorrect syntax near '@aProcess'.

Any suggestions, ideas, etc. would be Appreciated!!

Thanks.

View 2 Replies View Related

KILL Processes, Help To Do This!!!

Sep 20, 2000

Hi,

How to kill process???
I turn off workstation but the process still available in the sysprocesses table and in the Curent activity window.
I can't to kill this (and I can't to restart serever, because the users) .

If anyone know something about this problem.
Thanks

View 2 Replies View Related

Kill Old Transactions

Nov 9, 1999

Does anyone have a script for killing transactions older than 24 hrs? I have been having problems with users bootting out and leaving open transactions, I'd like to clean up all the orphans early every morning.

I am trying a WHILE on DBCC OPENTRAN.

We are using TCP/IP sockets, apparently they never notify the db server that the user has dropped, sockets stay open by default.

TIA

View 4 Replies View Related

KILL Spid

Feb 19, 1999

I can not stop a process using 'KILL spid'.What else should I try?
process has begun a transaction and does not commit.

View 2 Replies View Related

Kill All Processes In A Particular DB

Sep 26, 2006

/*
The Following Stored Procedure helps to
Kill All Processes in a Particular DataBase
With Out Current Process
*/

Create Proc Sp_KillAllProcessInDB

@DbName VarChar(100)

as
if db_id(@DbName) = Null
begin
Print 'DataBase dose not Exist'
end
else

Begin
Declare @spId Varchar(30)

DECLARE TmpCursor CURSOR FOR
Select 'Kill ' + convert(Varchar, spid) as spId
from master..SysProcesses
where db_Name(dbID) = @DbName
and spId <> @@SpId
and spId > 50
and dbID <> 0
OPEN TmpCursor

FETCH NEXT FROM TmpCursor
INTO @spId

WHILE @@FETCH_STATUS = 0

BEGIN

Exec (@spId)

FETCH NEXT FROM TmpCursor
INTO @spId

END



CLOSE TmpCursor
DEALLOCATE TmpCursor

end
/* The Above Query Helps TO Change a Database in Single USer Mode Quickly*/

View 5 Replies View Related

Kill Processes

May 8, 2002

I have been needing to disconnect users often, before backing up a database or setting it to restricted users.
Each time, I have to go to Current Activity & kill one process at a time. Is there a way, by which I can kill all processes on a database or force out all coonections to it?

Thanks.

View 4 Replies View Related

Can&#39;t Kill A Process

Sep 4, 2002

I have a process that a user somehow got locked on Master and can't kill the process. Tried EM and kill and still will not work. Any other ideas?

View 1 Replies View Related

How To Kill Process

Apr 5, 2001

SQL Server 2000.

Hi!
After I killed maintenance process (57) in the current activity window and run ‘kill 57 with statusonly’ I got message: ‘SPID 57: Estimated rollback completion: 100%. Estimated time remaining: 0 sec.’
When I reopened current activity window I still see that SPID 57 is runable.
Then I run select*from
sysprocesses where SPID = 57
It also reports that process status is runable.
What is the problem?
How can I remove (and should I) this record from masterdb.
Thank you,
Natalia

View 2 Replies View Related

Kill Process

Oct 4, 2006

Hi Peepz,

Im just a newbie using SQL Server anyway i noticed in my present company that most of the process/Stored Procedure that are being executed or connection that was being made by the application is not being terminated or disconnected. they use very large IO and CPU resources making the server slow or sometimes hang.(well that was my diagnostics). i try to kill them one by one but it seems endless process is redundant. to cut my problem short im thinking of having an application that would automatically kill all this unwanted process but ofcourse i should specify the parameter which process to kill. is this possible? i saw the KILL statement in the online books but it seems uncomplete with what i wanted to accomplish.

Thanks all

View 2 Replies View Related

Kill Process

Oct 4, 2006

Hi Peepz,

Im just a newbie using SQL Server anyway i noticed in my present company that most of the process/Stored Procedure that are being executed or connection that was being made by the application is not being terminated or disconnected. they use very large IO and CPU resources making the server slow or sometimes hang.(well that was my diagnostics). i try to kill them one by one but it seems endless process is redundant. to cut my problem short im thinking of having an application that would automatically kill all this unwanted process but ofcourse i should specify the parameter which process to kill. is this possible? i saw the KILL statement in the online books but it seems uncomplete with what i wanted to accomplish.

Thanks all

View 4 Replies View Related

Kill Processes

May 4, 2004

Can you kill processes in SQL Server 2K without stopping SQL Server and restarting it? I am using sp_who2 to get a list of active users and I see some accounts that are logged off but still showing up and I am trying to find a way to Kill these accounts and the processes they are doing.

View 3 Replies View Related

KILL Spid

May 8, 2008

can we just kill spid and drop it without doing any rollback ...?


Thanks,
ServerTeam

View 9 Replies View Related

Does KILL Rollback?

Jun 26, 2007

Hi All,

If I KILL a SPID, are any modifications automatically rolled back?

View 5 Replies View Related

Kill Connection

Feb 15, 2007

Hello,I do maintenance on the Back endand have like 10 - 20 connections open...specialized scrips i run and theydont need to be stored proc'sis there a way to kill the connection when the script is finished...from myclient side.....not just disconnect...cause server still has the pool of the connection...iwant to kill the pool'd connection alsothanksDave P

View 1 Replies View Related

I May Just Have To Kill Myself....Oracle

Sep 18, 2006

I have a stored procedure in Oracle.

I build the sql beautifully to call it with Openquery

"select * from OPENQUERY(MYLink,'DECLARE P_DATE VARCHAR2(20); BEGIN P_DATE := ''15-Sep-2006 17:26:09''; EXEC poPT (P_DATE); COMMIT; End;')

"Server: Msg 7357, Level 16, State 2, Line 1"

"Could not process object 'DECLARE P_DATE VARCHAR2(20); BEGIN P_DATE := '15-Sep-2006 17:26:09'; EXEC poPT(P_DATE); COMMIT; End;'. The OLE DB provider 'MSDAORA' indicates that the object has no columns."

I cannot seem to find away to make this work.

I wanted to return just the record count to make it happy but that did not work either.

The linked server is fine, the grants are fine.

I even tried this as a function in oracle to no avail.

I feel like I am going insane trying to make something that SHOULD BE SIMPLE work.

It's times like this that you really appreciate SQL Server....

Thanks for ANY help with this.



View 3 Replies View Related

Join Cursor With Table Outside Of Cursor

Sep 25, 2007

part 1

Declare @SQLCMD varchar(5000)
DECLARE @DBNAME VARCHAR (5000)

DECLARE DBCur CURSOR FOR
SELECT U_OB_DB FROM [@OB_TB04_COMPDATA]

OPEN DBCur
FETCH NEXT FROM DBCur INTO @DBNAME


WHILE @@FETCH_STATUS = 0
BEGIN

SELECT @SQLCMD = 'SELECT T0.CARDCODE, T0.U_OB_TID AS TRANSID, T0.DOCNUM AS INV_NO, ' +
+ 'T0.DOCDATE AS INV_DATE, T0.DOCTOTAL AS INV_AMT, T0.U_OB_DONO AS DONO ' +
+ 'FROM ' + @DBNAME + '.dbo.OINV T0 WHERE T0.U_OB_TID IS NOT NULL'
EXEC(@SQLCMD)
PRINT @SQLCMD
FETCH NEXT FROM DBCur INTO @DBNAME

END

CLOSE DBCur
DEALLOCATE DBCur


Part 2

SELECT
T4.U_OB_PCOMP AS PARENTCOMP, T0.CARDCODE, T0.CARDNAME, ISNULL(T0.U_OB_TID,'') AS TRANSID, T0.DOCNUM AS SONO, T0.DOCDATE AS SODATE,
SUM(T1.QUANTITY) AS SOQTY, T0.DOCTOTAL - T0.TOTALEXPNS AS SO_AMT, T3.DOCNUM AS DONO, T3.DOCDATE AS DO_DATE,
SUM(T2.QUANTITY) AS DOQTY, T3.DOCTOTAL - T3.TOTALEXPNS AS DO_AMT
INTO #MAIN
FROM
ORDR T0
JOIN RDR1 T1 ON T0.DOCENTRY = T1.DOCENTRY
LEFT JOIN DLN1 T2 ON T1.DOCENTRY = T2.BASEENTRY AND T1.LINENUM = T2.BASELINE AND T2.BASETYPE = T0.OBJTYPE
LEFT JOIN ODLN T3 ON T2.DOCENTRY = T3.DOCENTRY
LEFT JOIN OCRD T4 ON T0.CARDCODE = T4.CARDCODE
WHERE ISNULL(T0.U_OB_TID,0) <> 0
GROUP BY T4.U_OB_PCOMP, T0.CARDCODE,T0.CARDNAME, T0.U_OB_TID, T0.DOCNUM, T0.DOCDATE, T3.DOCNUM, T3.DOCDATE, T0.DOCTOTAL, T3.DOCTOTAL, T3.TOTALEXPNS, T0.TOTALEXPNS


my question is,
how to join the part 1 n part 2?
is there posibility?

View 1 Replies View Related

Kill Unnecessary Connections

Mar 22, 2004

how to determine which connections are unwanted...
i just ran the sp_who sp and heres the results i got...now how can i know unwanted connections form this list..


10background sa0 NULLLAZY WRITER
20sleeping sa0 NULLLOG WRITER
30background sa0 masterSIGNAL HANDLER
40background sa0 NULLLOCK MONITOR
50background sa0 masterTASK MANAGER
60background sa0 masterTASK MANAGER
70sleeping sa0 NULLCHECKPOINT SLEEP
80background sa0 masterTASK MANAGER
90background sa0 masterTASK MANAGER
100background sa0 masterTASK MANAGER
110background sa0 masterTASK MANAGER
120background sa0 masterTASK MANAGER
130background sa0 masterTASK MANAGER
510sleeping NT AUTHORITYSYSTEM 0 ReportServerAWAITING COMMAND
520runnable CENTCOMDinakar 0 BBMiniSELECT
550sleeping CENTCOMASPNET 0 BBMiniAWAITING COMMAND
560sleeping CENTCOMASPNET 0 BBMiniAWAITING COMMAND


thanks

View 3 Replies View Related

Unable To Kill Process

Jul 9, 2002

Hi,
Could anyone tell me why I am not able to kill processes even with kill spid. I had scheduled some db backups through DB Maintenance. All of them are running for days together when I tried to kill them spid. It still does not get killed. Can anyone tell me why

View 4 Replies View Related

Not Able To Kill Sleeping Process

Apr 20, 2001

I have SQL Server 7.0 and I am not able to kill one of the SPID's who is running a SELECT Statement and showing as sleeping.
When I saw in the current activity in EM I see the STATUS as sleeping
COMMAND as SELECT, APPLICATION as Microsoft Transaction server, WAITTIME as 7877 and WAITTYPE as EXCHANGE and CPU 10074
Thanks in advance.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved