SP Or Query To List Locks Or Deadlocks ?

Sep 18, 2006

What could be the query or the stored procedure to list locks or deadlocks ?


Thanks

View 2 Replies


ADVERTISEMENT

Transact SQL :: How To List All Locks (including NON-BLOCKING Locks)

Aug 5, 2015

We are migrating our database(s) from ORACLE to SQL. In Oracle we were able to issue a SELECT statement and see all of the locks (Blocking and Non-Blocking) currently in the system.  The query also included the Process ID of the process we needed to kill in order to get rid of the lock.

We now need to create the same type of query for Microsoft SQL Server 2012. I have seen postings on different sites saying that this info can be obtained using SP_WHO2 or using the SQL Server Management Studio Activity Monitor's PROCESSES tab, but we are looking for a SELECT statement that will give us similar information.

View 7 Replies View Related

Transactions, Locks And Deadlocks

Jul 20, 2005

Hi ChapsCan someone point me in the right direction for a very in depthpractical treatment of this for sql2k.Seen a number of books that skirt around it, read some articles thattouch on it (including some of erlands) but I need more...Thanks for any tips!

View 1 Replies View Related

How To Avoid Deadlocks Using Locks On Transactions

Sep 21, 2015

I'm a web developer. our system uses sql server 2012 since it was put in an environment production, what happened one year ago, but only now we are facing a disturbing problem. what happens it's that, when 30 users try to do the same operation in the database, we are getting deadlock status from the db in a few time. we did put this system in production one year ago and now we are facing this kind of problem.

We know that in other dbms using an optimistic lock solves the problem, but it's not our case, 'cause the users are not doing the same operation in a row.

We develop our system in java ee and our db is sql server 2012. These operations might be done on our api.

View 3 Replies View Related

Deadlocks And Parallel Query Processing

Dec 9, 2005

SQL Server 2000 SP3ALast week one of our processes starting issuing or suffering deadlockdetected errors every 15 minutes or so.I have read several articles at MS on the subject. I set a couple ofstartup parameters related to producing deadlock detection informationand ran SQL Profiler. I found the SQL statements being issued by thedeadlocked statements. In every deadlock the same UPDATE statementappears however the data values being searched on are different. Thebest I can tell from trying to query the actual data each update hitsonly one or very few rows. No indexed column is updated so the indexesshould not be the source of conflict.Looking at the query I noticed that the query does not have anavailable index and Query Analyzer shows that the full table scan isbeing done in parallel.My question: Does SQL Server change or modify its locking rules whenqueries are converted to be ran using parallel processing? If so, doyou have a reference?Here is the deadlock entries posted to the error log:SPID=167ResType:LockOwner Stype:'OR' Mode: IX SPID:63 ECID:0 Ec:(0x65971510)Value:0x3c577e60 Cost:(0/0)Input Buf: Language Event: UPDATE Station_Upload setStation_Accept_Status = 'ACC',HeadStatus ='ACC',LastProcessedSta='110',HeadPartType='1' WHERE Part_Serial_No ='SCH1119323' AND Station = 'H110'SPID=63ResType:LockOwner Stype:'OR' Mode: IX SPID:167 ECID:0 Ec:(0x65801510)Value:0x3c27d060 Cost:(0/0)Input Buf: Language Event: UPDATE Station_Upload setStation_Accept_Status = 'ACC',HeadStatus ='ACC',LastProcessedSta='70',HeadPartType='1' WHERE Part_Serial_No ='SCH1119060' AND Station = 'H070'I have suggested adding an index to support the query.Any ideas?Thanks -- Mark D Powell --

View 4 Replies View Related

Recovering From Deadlocks: Retrying The Query

Aug 17, 2006

I'm having some deadlocking issues in my ASP.Net 2.0 web application with SQL Server 2000. One solution I've come across involves catching the the deadlock error (at the application level) and then retrying the query again, in the hopes that whatever was causing the deadlock is no longer locked.

I've tried to implement such a solution, where I catch the deadlock exception, then try to execute the same query again. Only now I'm getting a "The transaction is in doubt" exception.

So am I going about this wrong? Am I supposed to retry the entire transaction, or is valid to just try to redo the one query that it failed on? Is there some way around the transaction being in doubt?

View 1 Replies View Related

SQL Server 2008 :: Row Locks Not Escalating To Table Locks After 5000

Jul 16, 2015

I've got an INSERT that's selecting data from a linked server and attempting to push 10 million rows into the blank table. More or less, it looks like this:

insert into ReceivingTable (
Field1, Field2, Field3, Field4
, Field5, Field6, Field7, Field8
, Field9, Field10, Field11, Field12
, Field13, Field14, Field15

[code]...

The instance of the SQL Server Database Engine cannot obtain a LOCK resource at this time. Rerun your statement when there are fewer active users. Ask the database administrator to check the lock and memory configuration for this instance, or to check for long-running transactions. There are no other active users. I ran it again and monitored the following DMO to watch the growth of locks for that spid:

SELECT request_session_id, COUNT (*) num_locks
-- select *
FROM sys.dm_tran_locks
--where request_session_id = 77
GROUP BY request_session_id
ORDER BY count (*) DESC

The number of locks started small and held for a while around 4-7 locks, but at about 5 minutes in the number of locks held by that spid grew dramatically to more than 8 million before finally erroring again with the same message. Researching, I can't figure out why it's not escalating from row locks to table locks at the appropriate threshold. The threshold in was set to 0 at first (Server Properties > Advanced > Parallelism > Locks). I set it to 5000, and it still didn't seem to work. Rewriting the INSERT to include a WITH (TABLOCK) allows it to finish successfully in testing. My problem is that it's coming out of an ETL with source code that I can't edit. I need to figure out how to force it to escalate to locking the entire table via table or server level settings.

A colleague suggested that installing service packs may take care of it (the client is running SQL Server 2008 R2 (RTM)), but I haven't found anything online to support that theory.

View 9 Replies View Related

Query Analyzer Locks Up!

Jul 23, 2005

Hey all,I'm having this weird problem on my Windows 2003 Server machine..Whenever I open two connection pages in Query Analyzer, then close oneof them, it locks up and I have to kill the task.I read a posting somewhere that said this could be due to an MDACinstallation problem, but I've run MDAC Component Checker and all filesare ok, version 2.8. Also, since I'm running Windows 2003 and MDAC 2.8is the latest, I can't reinstall it.There has to be some other cause for this. Why would QA lock up everytime I close a page?-John

View 11 Replies View Related

Items In List A That Don't Appear In List B (was Simple Query...I Think)

Jan 20, 2005

Ok, I want to write a stored procedure / query that says the following:
Code:
If any of the items in list 'A' also appear in list 'B' --return false
If none of the items in list 'A' appear in list 'B' --return true


In pseudo-SQL, I want to write a clause like this

Code:

IF
(SELECT values FROM tableA) IN(SELECT values FROM tableB)
Return False
ELSE
Return True


Unfortunately, it seems I can't do that unless my subquery before the 'IN' statement returns only one value. Needless to say, it returns a number of values.

I may have to achieve this with some kind of logical loop but I don't know how to do that.

Can anyone help?

View 3 Replies View Related

Query With View Locks Database (was Problem With Viiews)

Jan 20, 2005

Hi,
I am joining a table with a view in my query to get the desired data. But when I run this query it does not produce any result, instead the execution goes on never ending finally locking the database.
Surprisingly if the selected data from this view is put in a temporary table and that table is joined with the table to get the result, it works fine.

Could anybody please help me with this as creating a table every time would be slow procedure. Is there any restrictions related to views which may be I have ignored.

Thanx in advance.

Regards,
Sushma

View 1 Replies View Related

Does It Locks Database/tables When Only Select Query Comes In SQLTransaction

Jul 12, 2006

Hi,

I want to make SQLTransaction as global and use it checking the State.
But then where there are Only Select queries are going to fire, it will open transaction.

So, Does it locks database/tables when Only Select query comes in SQLTransaction.

If you have another successful way of doing this, Please suggest.

Thanking you.

tats

View 8 Replies View Related

T-SQL (SS2K8) :: Prevent SELECT Query From Returning Results Using LOCKS

Dec 2, 2014

I am trying to find a way to lock rows of data used in a SELECT query from being read by another SELECT query.

I could do a "begin tran - select - update - rollback" sequence but was wondering if there is a cleaner way to do this??

Tried UPDLOCK, ROWLOCK, TABLOCK, HOLDLOCK in multiple variations but none seem to block the select.

View 9 Replies View Related

SQL Server 2014 :: Query Causing Blocking / Locks Table For 1000 Seconds?

Feb 11, 2015

I have a sql snippet from a 3rd party application that will not complete its transaction. The SELECT statement executes but does not finish. Instead the statement just sits in AWAITING COMMAND for 1000 seconds then dies, thus killing the UPDATE statement that is supposed to follow.

The CROSS JOIN and CROSS APPLY seem suspect.

(
@p0 DATETIME,
@p1 INT,
@p2 INT,
@p3 NVARCHAR(4000),
@p4 INT,

[code]....

View 9 Replies View Related

SQL Server Admin 2014 :: SPID Causing Locks With No Query Text Shown

Oct 1, 2015

I just ran into an issue with cascading locks due to a SPID on one of my production servers. When researching the lock, I noticed that there was no sql text. SP_Who 2, nor the following query captured anything,

SELECT sqltext.TEXT
, sqlplan.query_plan
, req.session_id
, req.status
, req.command

[Code] ....

I spoke to the user causing the lock and he ran into a visual basic error when this occurred and didn't close out that window. So my guess is that it's due to an uncommitted transaction. However, shouldn't I still see something if that was the case?

View 4 Replies View Related

Query A List Of Databases

Oct 23, 2006

anyone know how to query a list of databases?

current the sp_helpdb seems cant help me, because it query all the details, i want to do it like select * from database where database id=2

View 5 Replies View Related

SELECT IN List Query

Apr 2, 2008

I have a table that has a list of skills, ie "HP One", "HP Two"

I need to pass the these skills from my applications search page to a stored procedure, hence I have a snippet of the SP below.

DECLARE @SkillSet NVarChar (200)
SET @SkillSet = '-HP One-,-HP Two-'
SET @SkillSet = Replace(@SkillSet, '-', '''')
SELECT * FROM CPSkillMatrixLevels WHERE SkillMatrixLevelName IN (@SkillSet)

The following sp does not return any results, but when i set the last line to ..

SELECT * FROM CPSkillMatrixLevels WHERE SkillMatrixLevelName IN ('HP One', 'HP Two')

It returns a set of results. Also when I do a select on the variable @SkillSet, ie SELECT @SkillSet, it displays 'HP One', 'HP Two'

Can enybody help me here, i Know i'm doing something wrong, but I cant think of what it is.

Thanks

View 6 Replies View Related

Query To List All Indexes In Db

Oct 17, 2007

Can someone help me with Query to list all indexes (name, table, field etc.) on a particular user/dbo database in sqlserver.

Thanks

View 3 Replies View Related

SQL Query To Check Against A List

Jul 23, 2005

SQL gurus...I have one table of items that is the master file. We will call this Table A.I have another table that contains few, some or all items from Table A. Wewill call this Table B.I want to run a query that compares the list of items on Table B against themaster list on Table A.If the item is not present on Table B, show it in the SQL results.Best way to achieve this? I am looping and doubling results in my sql tries.Jeff--Message posted via http://www.sqlmonster.com

View 1 Replies View Related

Query SharePoint List

Jan 31, 2008



Does anyone have any way to run a query against Sharepoint to return the content of a list through transact SQL?. Perferably without having to go throught the "back door" and access the Sharepoint database directly?

Thanks

View 1 Replies View Related

SQL Statement - Query A List Of Values

Oct 31, 2006

Hello  I have a newbie question.  If I have a table of the form:Table1{id, name} with the valuesid: 9 , name: test1,id: 7 , name: test2,id: 3 , name: test3,id: 15 , name: test4, id: 5 , name: test5,id: 13 , name: test6,.........If I have a list generated from user selection ( LIST{1, 7, 8, 15} ,) will I in a way be able to use this list in a query of the form, thus only having to make one query to the database: SELECT id, nameFROM Table1WHERE Table1.id in LIST Or is the solution to make multiple queries to the database, one for each member of the list, of the form:SELECT id, nameFROM Table1WHERE ID = @IDThanks in advance /dresen 

View 4 Replies View Related

Query List Of Datetimes For Same Date

Jul 7, 2007

Hi:I have created a table that has a column of smalldatetimes.  For any given day, there may be different records with the same date but with different times.  I've created the query SELECT Event FROM Events where Start=@Start and I input start as a selected date from the calendar control.  Because of the different times, I do not get any matches.   Could someone help me with a query that will get all of the events on the same day? Regards,Roger 

View 2 Replies View Related

SQL Query Linked To Drop Down List

Jan 20, 2008

I have a drop down list populated using sqldatasource1 it is populated with [item]
However, I need it to be poplulated with the three fields below AND, I don't want duplicates.  
SELECT [Item], [Alias1], [Alias2] FROM [Authors]
 

View 6 Replies View Related

Query To Get List Of Tables From Database

Sep 21, 2004

Can some one please tell me whats a best way ot get a list of all the tables that are present in a particular database.
Thanks

View 1 Replies View Related

Query To List Indexes From A Table ?

Sep 1, 2006

How can I list indexes with a (SQL) query ?
Thanks

View 1 Replies View Related

Query List Of All Tables In A Database

Mar 5, 2014

I'm running SQL Server 2012 Express. I need to query a database and return the list of tables in the database. How to construct this query?

View 4 Replies View Related

Parameterized Query For A List Of Items

Sep 2, 2014

I am doing parameterized queries from Visual Basic in Visual Studio.

I have a query where I want to do something like this.

Select * from people where city in (<list of cities>)

The problem is I want to build my <list of cities> in Visual Basic and pass it to the SQL as a parameter.

I know I can't do this:

Select * from people where city in (@ListOfCities)

Currently, I'm doing this by writing the <list of cities> out to a separate table, just so I can do the query.

Select * from people where city in (Select CityName from CityTable)

View 4 Replies View Related

List Items From A Form Query

Feb 24, 2008

Hi,
I am a newbie, this is my first post (please go easy).

Iam at the moment trying to set up a query for someone looking for a property on an estate agents website.

From a drop down menu, the user can:
select an area (where they may like to live) from a list of areas.
select an amount of bedrooms from a list of bedrooms
select a minimum price from a list of prices
select a maximum price from a list of prices.

The query I worked out for this is as follows:
$data = mysql_query("SELECT * FROM property WHERE area like '$area' and bedrooms like '$bedrooms' AND price BETWEEN '$min_price' AND '$max_price'") or die(mysql_error());

This seems to work fine and shows all the properties that meet the criteria onto my webpage.

However, I then thought, someone may not care which area they live in and want to see all properties in all the areas, so I decided to add the option 'All areas' to my 'areas' list, I then did the same for the other lists, eg 'all bedrooms' option to my bedrooms list and so on.

I am now trying to write a query that incorporates where the 'all..' option is selected and have become very stuck!
Can someone set me off in the right direction for this.
I hope that makes sense?!?!

View 20 Replies View Related

Transact SQL :: Query To Get DB List And Size

Nov 19, 2015

I need to retrieve list of all databases and the size occupied by them in sql server. As of now am pulling data for each database using sys.dqatabase_files which is hard for me as there are around 40-50 db on SQL Server.

View 4 Replies View Related

How To Query A Sharepoint List From SSIS

Jan 2, 2008

I have been searching for a GOOD example of using SSIS to query MOSS 2007 list data. I just want to return the data from a list in Sharepoint and use that data in SSIS. It should be as simple as defining a data source to connect to a specific list and return the rows like a SQL query.

Can anyone provide a good example of doing this in SSIS (and by the way, I'm not looking for how to write a C# program) - I want to be able to do this directly from SSIS.

Any help would be greatly appreciated.

View 4 Replies View Related

SharePoint Query On List - RsCompilerErrorInExpression

Aug 14, 2007

I have been working on this all day. First day using SQL Reporting Services.

Software being used -

VS2005 - SQLServer Business Intelligence Studio - with SharePoint Windows Services 2.0 Web Services

1. I have created a Data Source - XML - Which is a SharePoint List

http://xxx.xxx.com/sites/OpRiskSP/OpRiskTechPM/MMUpdate07/_vti_bin/lists.asmx

Passed

2. Next I go to create a DataSet - ds

<Query>
<Method Namespace="http://schemas.microsoft.com/sharepoint/soap/" Name="GetListItems"/> <SoapAction>http://schemas.microsoft.com/sharepoint/soap/GetListItems</SoapAction>
</Query>


Parameters
1. Name = listName, Value = MaturityModelWorkingCopy

Next I Run the query and boom the data returns
Then I click the refresh button to populate the Reprots Datasets - called ds

Passed

3. Layout

I am assuming you can drag and drop the data fields onto the designer which that does work
I drag the first dataField and I get a textbox =

=First(Fields!ows_ID.Value)

Not sure what the First stands for

4. Preview

FAILED


[rsCompilerErrorInExpression] The Value expression for the query parameter €˜listName€™ contains an error: [BC30451] Name 'MaturityModelWorkingCopy' is not declared.

Build complete -- 1 errors, 0 warnings

Any help would be grand.

<moojjoo />







View 5 Replies View Related

How Will I Create A Delimited List In A SELECT Query?

Jun 10, 2007

SELECT FriendName from Friends where RegionId = 23
I would like to create a comma delimited list of 'FriendName' column values in above query (example - Mike,John,Lisa,Emburey).
How would I do that?

View 5 Replies View Related

MSSQL Query To List Out Unique Records

May 22, 2008

 hilet me explain my need..following are the tables im using..tbl_company (company table - parent)    id    company    1    test    2    test123    tbl_dept (department table - master)    id    dept    1    dept1    2    dept2tbl_compdept (company departments table - child)    cmpid    deptid    1            1    2            1    2            2    wats my need is.. while the company is listing..by query using joins, result was like this..company        depttest                dept1test123           dept1test123           dept2i need company test123 should be listd only once..when i use group by or distinct means, all r listed..is there any way to filter out therepeating company list by just listing the company list only once..

View 5 Replies View Related

Build SQL Query From Dynamic Checkbox List

Nov 26, 2003

Not sure if this is the place to post this, but here goes.

I need to setup an options screen where my customers can customize which locations will be stored for their user id when pulling reports. I have checkbox list that dynamically loads their locations. I need to store the selected checkbox items in my table and then each time they login in to run a report, it will use the stored Location values in my SQL query.

Synopsis:
Selected locations stored in table. When the report is ran, the location values are pulled and added to my queries WHERE clause.

Thanks.

View 1 Replies View Related







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