VB6 SQL Server 2005 Lock Problem

Mar 22, 2007

We have an old VB6 app using a SLQ Server 2005 database.

This database is also used by a web service.

When accessed just by the VB6 or WebService everything runs smoothly.

The problem occur`s when both access the database in parallel.

Our web service seem`s to encounter some very long delay for queries running just fine when is alone.

Now my knowledge of VB6 is very limited (and it will stay that way :) i`ve checked the code for access part and some parts look obscur.

so here is the part where the queries gets executed

Set m_adoRecordSet = New ADODB.Recordset
With m_adoRecordSet
.CursorLocation = iCursorLocation
.CursorType = iCursorType
.LockType = iLockType
Set .ActiveConnection = objConnection
.Open m_strSQL
End With

i looked everywhere in the code and iCursorLocation is mainly always SQLClient. i think only one time is SQLServer.

iCursorType is always SQLForwardOnly and iLockType is always SQLReadOnly.

now the curious part (for me) is that the connection (objConnection) is opened at the beginning of the app and never closed? Is that normal in VB6?

Would the cursor being sometimes on the server be the problem?

If someone could help it would be very appreciated.

If you need more details just tell me.

thanks

mateo

View 1 Replies


ADVERTISEMENT

Lock Down SQL Server 2005

Feb 12, 2008

Hi there,

I just wrote an article on how to Lock Down SQL Server 2005 that might interest people here. It has step-by-step instructions and SQL scripts for server and database hardening. A lot of concepts are explained along the way.

As an experiment I also have a world-accessible SQL2005 shell to let people experiment with a hardened database and see if they can do privilege escalation. A lot of the standard tricks have been tried so far and the server has held up without any problems. I wonder if that will last

Anyhow, the article is here: http://duartes.org/gustavo/articles/Lock-Down-SQL-Server-2005.aspx. I appreciate all feedback.

cheers,
Gustavo

View 3 Replies View Related

SQLBulkCopy In A C# App Causes SQL Server 2005 To Lock Up

May 16, 2007

I have written an app that will allow you to send a query to Teradata, return the results into a Reader and then Bulk Copy that data into SQL Server 2005.



If the query results in a large dataset (ie 20,000,000 rows) is processed then while that data is being bulk copied into SQL Server, using the SQLBulkCopy class, then it prevents users on other computers from logging into SQL Server Management Studio.

Those that are already logged in are shut down also. Everything appears fine to the users but queries do not finish running.



Everything immediatly starts working as normal when either my program finishes or I shut down my program.



Is there any type of property to the SQLBulkCopy class or any other function that will prevent Management Studio from locking up?



Thanks

Robert

View 2 Replies View Related

Why Does The Index Lock My Updates In SQL Server 2005?

Mar 28, 2006

When one process has one record locked in Update-Mode then an other process can't update any other records on that table with some queries, other queries that access the same records (but with a different WHERE statement) will execute.
This problem occurs with SQL Server 2005, but it didn't with SQL Server 2000 (or any other database).

The problem:
-Process 1 locks a record in the table, and keeps it in Update-Mode, because the user is editing it. (Using OLEDB Pessimistic Cursor-locking)
-Process 2 wants to update an other record, buts gets a "Lock timeout" when using one query but not with another.

For example this query will work :
UPDATE gwseqnumber SET nextseqnr = 3 WHERE row_id = 110;

But this qeury will give me a "Lock timeout" :
UPDATE gwseqnumber SET nextseqnr = 3 WHERE name = 'REC_2';

But it is the same record!!
The record with name = 'REC_2' has the row_id = 110, both values are unique in the table.

The data:
The table [gwseqnumber] has the following CREATE statement:
CREATE TABLE GWSEQNUMBER
(
    NEXTSEQNR                      INTEGER,
    NAME                      CHAR (20),
    ADMINISTRATIONCODE             INTEGER,
    FINDHIGHESTNUMBER              CHAR (1),
    CLOSEDYN                       CHAR (1),
    ROW_ID                      INT IDENTITY(1,1) NOT NULL
);

CREATE INDEX KEY_1 ON GWSEQNUMBER (NEXTSEQNR);
CREATE UNIQUE KEY_2 ON GWSEQNUMBER (ADMINISTRATIONCODE, NAME, IDENTIFIER);
CREATE UNIQUE INDEX KEY_3 ON GWSEQNUMBER (ROW_ID);

Both KEY_2 and KEY_3 are unique, KEY_1 is not.


If I remove the index on the NEXTSEQNR column (the index named KEY_1) then both these queries will work, so it is obviously related to the index.
Altough the index is obsolete and can be removed from this table, it should not result in bogus locking errors.

Even when i removed the index not all the queries will work. (With work i mean not run into a locking error, while the record is not even locked.)



Solutions tried:
- Set the compaitiblity level of the databsae back to 80 (for SQL Server 2000 compatibility).
- I have already tried to disable Page-Locking on all the indexes of this table.


So why does the index lock my updates in SQL Server 2005?
And how do i fix it so my database does not run into these locks?

View 14 Replies View Related

SQL Server 2005 Service Pack 1 Causes Machine Lock Up

May 30, 2006

When doing the service pack 1 install on a client side the machine is locking up on a specific file. The tech who tried it out doesn't remember the exact file name but he thinks it ended with an .msb or .msp

I checked in the C:Program FilesMicrosoft SQL Server90Setup BootstrapLOGFiles directory and none of the files have been updated.

Thoughts?

Shane

View 1 Replies View Related

Adding Table To Dataset For SQL Server Mobile Causes VS 2005 To Lock Up.

Apr 20, 2006

I am running VS 2005 Professional Edition

Windows XP profession with Service Pack 2

SQL Server 2005 Developer Edition.

WHAT I HAVE DONE:

I have a database running in an instance of SQL Server.

I set this up for merge publication and then set up a SQL Server Mobile Edition Subscription to that publication.  After a few oversights I got everything working.  The Mobile database replicated just fine.  I went back verified all data was there.  Can make queries to it.

 

PROBLEM: 

I set up a new dataset to use tables from the SQL Server Mobile database.  If I drag one of the tables to the dataset, VS 2005 simply stops responding.  It is not using any processor. I click any place on the application and I get the Microsoft Visual Studio Delay Notification saying:

Microsoft Visual Studio is Busy.

Microsoft Visual Studio is waiting for an internal operation to complete.  If you regularly encounter this delay during normal usage, please report this problem to Microsoft.

Well...  It is more than just a delay.  The environment is not using any processor its just sitting here.  And I left it running for 2.5 hours...  so now this is becoming a big source of pain for me because I need to get that dataset working to finish my business logic.  The only option I have is to Kill the process.

Hopefully someone out there can help.

Additional Services running:

IIS (Whatever version comes with Windows XP Pro.  I think 5.1)

SQL Server Agent, SQL Server Integration Services, SQL Server Broswer and SQL Server FullTextSearch

UPDATE:  I am editing this post with an update.

I noticed that my other tables get added to the dataset just fine.  It is when I add one particular table that the entire visual studio simply stops and starts giving the delay notification.  I have no idea why this happens... nor do I see any noticeable difference between this table and the rest of them.  I went back and made sure that all columns types where directly supported by SQL Mobile Edition and they are.

 

View 14 Replies View Related

Error: A Deadlock Was Detected While Trying To Lock Variable X For Read Access. A Lock Could Not Be Acquired After 16 Attempts

Feb 2, 2007

I simply made my script task (or any other task) fail

In my package error handler i have a Exec SQL task - for Stored Proc

SP statement is set in following expression (works fine in design time):

"EXEC [dbo].[us_sp_Insert_STG_FEED_EVENT_LOG] @FEED_ID= " + (DT_WSTR,10) @[User::FEED_ID] + ", @FEED_EVENT_LOG_TYPE_ID = 3, @STARTED_ON = '"+(DT_WSTR,30)@[System::StartTime] +"', @ENDED_ON = NULL, @message = 'Package failed. ErrorCode: "+(DT_WSTR,10)@[System::ErrorCode]+" ErrorMsg: "+@[System::ErrorDescription]+"', @FILES_PROCESSED = '" + @[User::t_ProcessedFiles] + "', @PKG_EXECUTION_ID = '" + @[System::ExecutionInstanceGUID] + "'"

From progress:

Error: The Script returned a failure result.
Task SCR REIL Data failed

OnError - Task SQL Insert Error Msg
Error: A deadlock was detected while trying to lock variable "System::ErrorCode, System::ErrorDescription, System::ExecutionInstanceGUID, System::StartTime, User::FEED_ID, User::t_ProcessedFiles" for read access. A lock could not be acquired after 16 attempts and timed out.
Error: The expression ""EXEC [dbo].[us_sp_Insert_STG_FEED_EVENT_LOG] @FEED_ID= " + (DT_WSTR,10) @[User::FEED_ID] + ", @FEED_EVENT_LOG_TYPE_ID = 3, @STARTED_ON = '"+(DT_WSTR,30)@[System::StartTime] +"', @ENDED_ON = NULL, @message = 'Package failed. ErrorCode: "+(DT_WSTR,10)@[System::ErrorCode]+" ErrorMsg: "+@[System::ErrorDescription]+"', @FILES_PROCESSED = '" + @[User::t_ProcessedFiles] + "', @PKG_EXECUTION_ID = '" + @[System::ExecutionInstanceGUID] + "'"" on property "SqlStatementSource" cannot be evaluated. Modify the expression to be valid.

Warning: The Execution method succeeded, but the number of errors raised (4) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the errors.

And how did I get 4 errors? - I only set my script task result to failure

View 11 Replies View Related

Row Lock Versus Page Lock In SQL 2000.

Apr 7, 2004

Hi
We are facing an acute situation in our web-application. Technology is ASP.NEt/VB.NET, SQL Server 2000.

Consider a scenario in which User 1 is clicking on a button which calls a SQL stored procedure. This procedure selects Group A of records of Database Page1.

At the same time if User 2 also clicks the same button which calls same SQL stored procedure. This procedure selects Group B of records of Database Page1.

So, its the same Page1 but different sets of records. At this moment, both the calls have shared locked on the Page1 inside the procedure.

Now, in call 1, inside the procedure after selecting Group A of records, the next statement is and update to those records. As soon as update statement executes, SQL Server throws a deadlock exception as follows :

Transaction (Process ID 78) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction

We are able to understand why its happening. Its because, Group A and Group B of records are on the same Page1. But both the users have shared lock on the Page1. So, no one gets the exclusive lock in records for update, even though, the records are different.

How can I resolve this issue? How can I get lock on wanted rows instead of entire page?

Please advice. Thanks a bunch.

Pankaj

View 1 Replies View Related

Lock Pages In Memory Option On SQL 2005 STD 64-bit With W2K3 R2 Standard 64-bit - Does It Work?

Nov 9, 2007

Hey Folks -

I'm setting up a new production SQL 2005 64-bit server running on a dedicated Windows 2003 R2 Standard system w/8GB of RAM.

I've enabled the "Lock Pages in Memory" option (http://msdn2.microsoft.com/en-us/library/ms190730.aspx) but when I run dbcc memorystatus all of my AWE counters show 0.

According to http://blogs.msdn.com/sqlprogrammability/:

"On 64 bit machines, execute 'dbcc memorystatus'. If the AWE Allocated memory is 0 then lock pages in memory privilege has not been granted to the service account or it has not taken effect. "

Does the "Lock Pages in Memory" option work on W2K3 R2 Standard? Just searching across the web I find different answers. In some places it clearly says that Lock Pages in Memory only works on W2K3 Enterprise systems. In other places it says that it should work on any Windows 2003 64-bit OS.

Does anyone have any ideas? Assuming we cannot "lock pages in memory" due to the Windows 2003 Standard OS, are there any other memory management recommendations out there?

thanks!

View 2 Replies View Related

ERROR: A Variable May Only Be Added Once To Either The Read Lock List Or The Write Lock List.

May 22, 2006

Hi,
I have set of 2 DTS packages, one of which calls the other by forming a command-line (dtexec) using a Execute Process task.

From the parent package-> Execute Process Task->
dtsexec /F etc... /<pkg variable> = "servername"

Each of the parent and the called package have a variable: "User::DWServerSQLInstance" which is mapped to the SQL server connection manager server name property using an expression. The outer package has the above variable and so does the inner called package (which gets assigned through the command line from the outerpackage call to inner)

I "sometimes" get the following error:

OnError,I4,TESTDOMAdministrator,ACDWAggregation,{A1F8E43F-15F1-4685-8C18-6866AB31E62B},{77B2F3C7-6756-46EB-8C01-D880598FB4B3},5/22/2006 5:10:28 PM,5/22/2006 5:10:28 PM,-1073659822,0x,The variable "User::DWServerSQLInstance" is already on the read list. A variable may only be added once to either the read lock list or the write lock list.

Help would be appreciated!

I have seen other posts on this but, not able to relate the solution to my scenario.

View 9 Replies View Related

A Variable May Only Be Added Once To Either The Read Lock List Or The Write Lock List

May 10, 2006

Hi All,



I have seen a few other people have this error.

Package works fine when run from BIDS, DTExec, dtexecui. When I schedule it, It get these random errors. (See below)

The main culprit is a variable called "RecordsetFileDIR" which is set using an expression. (@[User::_ROOT] + "RecordSets\")

A number of other variables use this as part of their expression and as they all fail, pretty much everything dies.

I have installed SP1 (Not Beta) on server. Package uses config files to set the value of _ROOT.



The error does not always seem to be with this particular variable though. Always a variable that uses an expression but errors are random. Also, It will run 3 out of 10 times without a problem. I am the only person on the server at the time.

Any ideas?



Cheers,

Crispin



Error log:

OnError,,,POSBasketImport,,,10/05/2006 12:03:34,10/05/2006 12:03:34,-1073659822,0x,The variable "User::RecordsetFileDIR" is already on the read list. A variable may only be added once to either the read lock list or the write lock list.

OnError,,,POSBasketImport,,,10/05/2006 12:03:34,10/05/2006 12:03:34,-1073639420,0x,The expression for variable "rsHeaderFile" failed evaluation. There was an error in the expression.

OnError,,,DF_Header_Header,,,10/05/2006 12:03:34,10/05/2006 12:03:34,-1071636247,0x,Accessing variable "User::rsHeaderFile" failed with error code 0xC00470EA.

OnError,,,Move All Data,,,10/05/2006 12:03:34,10/05/2006 12:03:34,-1071636247,0x,Accessing variable "User::rsHeaderFile" failed with error code 0xC00470EA.

OnError,,,Load Open Batches and Process Files,,,10/05/2006 12:03:34,10/05/2006 12:03:34,-1071636247,0x,Accessing variable "User::rsHeaderFile" failed with error code 0xC00470EA.

OnError,,,POSBasketImport,,,10/05/2006 12:03:34,10/05/2006 12:03:34,-1071636247,0x,Accessing variable "User::rsHeaderFile" failed with error code 0xC00470EA.

OnError,,,DF_Header_Header,,,10/05/2006 12:03:34,10/05/2006 12:03:34,-1071636390,0x,The file name is not properly specified. Supply the path and name to the raw file either directly in the FileName property or by specifying a variable in the FileNameVariable property.

OnError,,,Move All Data,,,10/05/2006 12:03:34,10/05/2006 12:03:34,-1071636390,0x,The file name is not properly specified. Supply the path and name to the raw file either directly in the FileName property or by specifying a variable in the FileNameVariable property.

OnError,,,Load Open Batches and Process Files,,,10/05/2006 12:03:34,10/05/2006 12:03:34,-1071636390,0x,The file name is not properly specified. Supply the path and name to the raw file either directly in the FileName property or by specifying a variable in the FileNameVariable property.

OnError,,,POSBasketImport,,,10/05/2006 12:03:34,10/05/2006 12:03:34,-1071636390,0x,The file name is not properly specified. Supply the path and name to the raw file either directly in the FileName property or by specifying a variable in the FileNameVariable property.

OnError,,,DF_Header_Header,,,10/05/2006 12:03:34,10/05/2006 12:03:34,-1073450901,0x,"component "rsHeader" (365)" failed validation and returned validation status "VS_ISBROKEN".

OnError,,,Move All Data,,,10/05/2006 12:03:34,10/05/2006 12:03:34,-1073450901,0x,"component "rsHeader" (365)" failed validation and returned validation status "VS_ISBROKEN".

OnError,,,Load Open Batches and Process Files,,,10/05/2006 12:03:34,10/05/2006 12:03:34,-1073450901,0x,"component "rsHeader" (365)" failed validation and returned validation status "VS_ISBROKEN".

OnError,,,POSBasketImport,,,10/05/2006 12:03:34,10/05/2006 12:03:34,-1073450901,0x,"component "rsHeader" (365)" failed validation and returned validation status "VS_ISBROKEN".

View 1 Replies View Related

MS SQL Server - LOCK Info

Feb 25, 2004

Hi

The system tables syslocks,syslockinfo give information on locked resources, spid, object_id,lock mode, lock status etc.

How will i get object_name

for example if a table is being locked above sys tables give object id, how can i get the actual table name ( object_name)

Please let me know
Best Regards
THNQdigital

View 4 Replies View Related

Sql Server Record Lock

Oct 3, 2007



I have a Sql Express Database that I want to access from a remote tablet application. When the remote user accesses a record (which is a form + ink), I can't have anyone else accessing that record and drawing ink on the record's form, unitl the first user is done. How do I prevent access to that record in a user friendly way until the remote user is done and has updated his changes to the database?

thanks!

View 6 Replies View Related

How To Lock A Table So Others Cannot Lock It

May 23, 2001

Hi,

I want to lock a table so others cannot lock it but able to read it inside transactions.

The coding I need is something like this: set implicit_transactions on begin transaction select * from table1 with (tablock, holdlock) update table2 set field1 = 'test' commit transaction commit transaction

I have tried the coding above, it won't prevent others from locking table1.

So, I changed the tablock to tablockx to prevent others from locking table1. But this will also prevent others from reading table1. So, how can I lock table1 so others cannot lock it but still able to read it?

Thank you for any help

View 1 Replies View Related

SQL Server 2008 :: No-lock Across Linked Server With Join?

Mar 9, 2015

I have two servers (lets call them sA and sB) connected from sA -> sB via a linked server (i.e. sA pulls data across from sB).

I'm building a temp table full of stock symbols on sA, and then I need to update some values on sA using content on sB. The tables on sB are very large (about 500m rows) so I don't want to pull even close to everything across the linked server. Ordinarily I'd do this by joining to the linked server table, but the target table needs to have nolock on it due to their high use.

update t
set someValue = s.SomeValue
from #myTab t
inner join lnk_sB.xref.dbo.Symbols s with (nolock)
on t.id = s.id

From reading around I gather that nolock doesn't work across linked servers. It was noted in another SSC article that you could use nolock by using an OPENQUERY, but then I can't join to my local temp table, and I end up pulling all .5B rows across the linked server.

Is there some way I can limit the content on sB by my temp table on sA but still use nolock?

View 9 Replies View Related

Obtaining A Table Lock In SQL Server

Apr 9, 2003

I need to lock a table in SQL Server. The reason is that I need to insert a value into an identity column (rather than just taking the next sequence number). I have a program that:

1. Sets identity insert on
2. Inserts into the table
3. Sets identity insert off

The problem is that I believe I should lock the table before I turn identity insert on (otherwise, other transactions will fail). I need to ensure that no other operations will take place on the table while I am doing all three of these steps.

I believe I can set the isolation level, but I cannot find any way to establish the lock without executing the update statement itself - which is a nanosecond too late to prevent another user from getting an error.

View 6 Replies View Related

Lock Issue On Production Sql Server

May 17, 2006

I have a 3rd party app which gets the error below on my sql 2000 box. I can't change the app or the db, so I am going to need to tweak sql to make the plane fly. The box is a new dell quad attached to a SAN. Runs on Win 2003 with 16 gig of RAM. 450 concurrent users. Anyone think more memory would help? I have the locks set to default. Are locks more of a memory killer, or CPU?

Error: 1204, Severity: 19, State: 1
The SQL Server cannot obtain a LOCK resource at this time. Rerun your statement when there are fewer active users or ask the system administrator to check the SQL Server lock and memory configuration.

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

View 3 Replies View Related

Row Level Lock In Sql Server 2000

Feb 23, 2006

Devteam writes "Hi,
WIndows version 5.0 (SP4)
I am using sql server 2000. in our application i am using simple select statement to retrieve the value from the database. Sometime the same query is accessed i did not get the result.i have tried to run the same query using query analyzer. but the query is keep on running. at the same time when accessing other rows in the table, it gets retrieve the values.

what is the problem here... is there anything locked that the row before executing the select statement.
if there is any lock is present then how to identify it and also how to prevent a row from locking... if the lock is occured then the other transactions also not executed. why the lock is placed in the first place."

View 1 Replies View Related

Does SQL Server Put A Shared Lock On All Tables Within A Transaction?

Feb 17, 2006

Would table1, table2 and table3 in code below, be locked with a shared lock from start of transaction to the end of transaction Or they would only be locked for the duration of  their update, or insert statements and not for the entire transaction? Default isolation level is in effect in SQL Server.
 begin tran   update table1 set column1 = 100   if @ERROR = 0     begin       declare @stat int       set @stat = (select stat from table2 where  employeeid = 10)      insert into table3 (col1, col2) values (@stat , 325)      if @@ERROR = 0          commit tran      else         rollback tran     end   else      roll back tran

View 2 Replies View Related

Server &#34;lock Up&#34; That Requires A Reboot To Recover

Feb 20, 1999

I have a situation that I was wondering if anyone has ever ran into before. It has to do with one of my MS SQL servers. The hardware is a ALR/Gateway 9000R with 4 PP200's, 1 Gb RAM, and a RAID 5 with 72 Gb storage. The NIC card is an ATM 155 Mbit card connected directly to our fiber backbone.

I have WinNT 4.0 Server Enterprise Edition loaded with SP4 and MS SQL Server 6.5 Enterprise Edition with SP5 installed.

I have 7 seperate active databases on the server supporting 7 different applications. The server has been on-line for approximately 4 weeks and just recently (last Thursday) it has started to "lock up" every couple of days. By lockup I mean that it starts to reject all requests by all users. No one can connect to the server including myself. The MS SQL error log grows and grows until we reboot the server. The error logs are 100 Mb or larger in size due to rejection errors being repeated over and over again.

There has been no change made to the server since initial installation.

The error in the MS SQL error log that keeps on being repeated is...
"Message 17308: Kernelerror - Lazywriter. Process (process ID number) generated access violation; SQL Server is terminating this process."

We have an incident in with Microsoft but they are not responding fast enough.

I was hoping that someone out there may have had this type of occurrance happen before.

Any suggestions?

Jim

View 1 Replies View Related

Can Get Server To Release A Lock Without Using Kill Command

Aug 26, 2015

Anyway I want to know if there is a way to get SQL Server to release a lock without using the kill command. My reason for asking is because this morning I was investigating some deadlocks and thought it would be nice if SQL Server upon identifying a deadlock instead of killing the victim SPID would simply force the victim SPID to release the lock causing the deadlock so that the other SPID could continue and the victim would simply have to wait longer.That lead me to wonder if there was a T-SQL command or DBCC to force SQL Server to release a lock that I specify.

So, any way to get SQL Server to release a lock without using the kill command?

View 8 Replies View Related

Possible To Lock A Row Within A Stored Procedure In SQL Server 2000?

Jul 20, 2005

Hi All,I have a table that holds pregenerated member IDs.This table is used to assign an available member id to web sitevisitors who choose to register with the siteSo, conceptually the process has been, from the site (in ASP), to:- select the top record from the members table where the assigned flag= 0- update the row with details about the new member and change theassigned flag to 1- return the selected member id to the web pageNow I'm dealing with the idea that there may be brief, high trafficperiods of registration, so I'm trying to build a method (storedprocedure?) that will ensure the same member id isn't returned by theselect statement if more than 1 request to register happens at thesame instant.So, my question is, is there a way, once a record has been selected,to exclude that record from other select requests, within the boundsof a stored procedure?ie:- select statement is executed and row is instantly locked; any otherselect statement running at that exact moment will receive a differentrow returned and sill similarly lock it, ad nauseum for as manysimultaneous select statements as take place- row is updated with details and flag is updated to indicate themember id is no longer unassigned- row is released for general purposes etcIf what I'm suggesting above isn't practical, can anyone help meidentify a different way of achieving the same result?Any help immensely, immensely appreciated!Much warmth,Murray

View 12 Replies View Related

Deadlocked On Lock Resources. SQL Server 2000

Jun 27, 2007

Hi, i am getting this error when i am running a stored procedure.



Transaction (Process ID XXXX) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.



i think so it is getting this error becasue it blocking it self at one point in the SP



DECLARE cty_Cursor CURSOR FOR
SELECT Country FROM TB_Country



declare @cty varchar(2)


OPEN cty_Cursor;
FETCH NEXT FROM cty_Cursor into @cty;
WHILE @@FETCH_STATUS = 0
BEGIN
EXEC SP_DO_SOMETHING @cty
FETCH NEXT FROM cty_Cursor into @cty;
END;
CLOSE cty_Cursor;
DEALLOCATE cty_Cursor;





i think so it calls the SP then before SP finsih its working it calls it back from cursor with other argument.



how we can make it sure it finish it execution before it is being called again. i think so we need some sort of lock here but i am not able to find right solution . please anyone suggest something.



Regards,

Haroon

View 2 Replies View Related

DEfault SQL Server 2000 Lock Modes

Jul 12, 2006

Hi everyone,
I wonder that SQL Server 2000 support the following lokc modes by default or not.

Shared (S)
Update (U)
Exclusive (X)

View 3 Replies View Related

SQL Server 2012 :: Perform Update But Skip Lock

Mar 7, 2014

I open query analyser and on one tab I update a record in a transaction and hold it.

begin tran
update customers set territory = 'x' where customer = 'A00001'
--rollback tran

In a second tab I attempt to update all records in the table

update customers set carrier = ''

Clear this fails because of the lock placed during the first script and this is fine.

However, is there a way to get the 2nd script to ignore the locked rows and just update as many as it can? The obvious answer seemed to be the READPAST hint like follows…

update customers with (READPAST) set carrier = ''

…but this is still blocked by the original lock. I’ve tried combining it with all sorts of other table hints but all seem to get blocked.

The following does work, ignoring the lock and not returning the data

Select * from customers with (READPAST) where customer = 'A00001'

I’ve tried combining this with the update like so…

update customers
set carrier = ''
from customers with (READPAST)
where customer = 'A00001'

..but this is blocked too.

I’m so desperate I tried moving the update into a cursor and update one row at a time. Nothing worked. I thought I might be able to do something like this

If (Select count(*)
from customers with (READPAST)
where customer = 'A00001') > 0
--then perform update

..but this returns a value of 1 even though the following returns no rows.

Select * from customers with (READPAST) where customer = 'A00001'

View 9 Replies View Related

SQL Server 2008 :: How To Find Order Of Lock Taken And Released

Feb 16, 2015

I have express edition [advance] of sqlserver 2008 r2 , is it possible to trace every event with out using profiler as u know it does not ship with it.

Basically i want to see how locks are taken and released in each isolation level when query is executed. I am using

SELECT resource_database_id, t.resource_type , t.resource_associated_entity_id,partitions.index_id,blocking_session_id,
indexes.name as index_name,o.name,
t.request_status, t.request_mode,t.request_session_id,
t.resource_description

[code]....

But i am not sure of the order becuase total_elapsed_time is same for many locks

like

resource_typeresource_associated_entity_idrequest_session_idrequest_modeindex_namenameresource_description
DATABASE051SNULLNULL
OBJECT209427886651Sch-SNULLwt
OBJECT209427886652IXNULLwt
PAGE7205759715088793652IXPK_wtNULL1:204815
KEY7205759715088793652XPK_wtNULL(4fb98fd9bfad)
DATABASE052SNULLNULL

View 5 Replies View Related

SQL Server 2008 :: Read A Value From Table And Increment It By 1 - Row Lock

May 12, 2015

I have a requirement to read a value from table and increment it by 1. There can be multi-threads doing the same operation and would need a ROW LOCK so that read and write both are atomic. How can i put an exclusive lock on the row before I read the value from the table.

CREATE TABLE [dbo].[tblOnboardingSequence](
[OnboardingSequenceID] [uniqueidentifier] NOT NULL,
[Name] [nvarchar](255) NOT NULL,
[NextNumber] [bigint] NOT NULL,
CONSTRAINT [PK_OnboardingSequence] PRIMARY KEY CLUSTERED(
[OnboardingSequenceID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

My Stored Procedure has below logic

DECLARE @NextNumber BIGINT
----------- Acquire row lock here
SELECT @NextNumber = NextNumber FROM tblOnboardingSequence WHERE Name = 'TPO'
UPDATE tblOnboardingSequence SET NextNumber = @NextNumber + 1 WHERE Name = 'TPO'
----------- Release row lock here

I would like to have a row lock for the row having Name "TPO" before SELECT query and release after UPDATE query.
What si the best way to deal with this?

View 2 Replies View Related

SQL Server 2008 :: Lock Out Users Without Affecting Replication?

Sep 1, 2015

We are approaching the "go live" date of a big application upgrade, so while the application is being upgraded i was asked to lock out all users and backup all databases and make sure the data isnt changed during a period of time

It turns out, as one of my databases is being replicated to another server, i cant put that database in read_only mode, or restricted_mode, without removing the replication.

Removing the replication means i have to set it up again and that means another 3 hours added to an already cram-packed weekend without sleep!

How I can lock out the users to make sure there are no changes to a database other then read_only/restricted_mode/single_user ?

I really don't want to touch that replication...

View 0 Replies View Related

Database Wars: Oracle Vs SQL Server Lock Escalation

Jul 20, 2005

I was at a conference and had it asserted to me by an Oracleafficiando that Oracle and DB2 handled low-level locks "better" thanSQL Server, and that this was likely the cause of SQL Server'srelatively slower and more deadlock-prone performance when running thesame application. (SQL does seem to perform more poorly for this app,a PeopleSoft customer service and billing app.)Is there any significant difference in lock escalation strategiesbetween major databases, and if so, what are the implications?Jeff Roughgarden, MSCD, MCDBA

View 1 Replies View Related

SQL Server 2000 Produces A Shared DB Lock With A Use DB. Normal?

Nov 20, 2007

Hi Folks,

I'm not a SQL Server expert, but need to understand something. I'm currently have SQL Server 2000 SP4 installed locally on my machine for application development.

Using sp_lock, I noticed that there are lots of shared database locks. After some study, i produced this interesting script:

use Master
go
sp_lock
go
use Experience
go
sp_lock
go

which results in:

spid dbid ObjId IndId Type Resource Mode Status
------ ------ ----------- ------ ---- ---------------- -------- ------
52 1 85575343 0 TAB IS GRANT
spid dbid ObjId IndId Type Resource Mode Status
------ ------ ----------- ------ ---- ---------------- -------- ------
52 13 0 0 DB S GRANT
52 1 85575343 0 TAB IS GRANT

My question is about the extra lock added by the "Use Experience statement". It lasts as long as the Experience DB connection is open

Question 1:
The way I read this is: the "use Experience" statement creates a shared database lock.
Am I reading this right?


Question 2:
I started looking into this because my application produces lots of locks that seem to live for 15-20 minutes. I have not noticed other adverse side effects of these locks. I have confirmed that nothing I have control over creates transactions, so I do not see why locks would be maintained.
Should I be concerned about these locks? Is this expected behavior?

Thanks Much in advance.

- D



View 3 Replies View Related

SQL Server 2014 :: Can Lock A Table Only For A Specific User For Some Seconds

Apr 8, 2015

I need to do some operations on a table when any user dont work with it.How do i do it?

Do i lock the table? and is it possible?(I dont want to deny permission from a user because cause error)

Can i do it with a open transaction ?

View 4 Replies View Related

SQL Server Admin 2014 :: Can Lock Table Only For Specific User For Some Seconds

Apr 8, 2015

I need to do some operations on a table when any user dont work with it.How do i do it?Do i lock the table? and is it possible?

View 8 Replies View Related

SQL Server 2012 :: Find Queries That Lock Tables Or Not Using Primary Key While Running Update

Jul 20, 2015

I need to search for such SPs in my database in which the queries for update a table contains where clause which uses non primary key while updating rows in table.

If employee table have empId as primary key and an Update query is using empName in where clause to update employee record then such SP should be listed. so there would be hundreds of tables with their primary key and thousands of SPs in a database. How can I find them where the "where" clause is using some other column than its primary key.

If there is any other hint or query to identify such queries that lock tables, I only found the above few queries that are not using primary key in where clause.

View 2 Replies View Related







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