Tracing Sql For Locks

Jul 20, 2005

I am fairly new to SQL Server. I am writing a tool in stored procedure
to identify locks in a table. I have already written the basic framework
of the SP. It will reside in master database and take two inputs. Database
name and table name. From that it will show all locks at that instant
on that table of that database. If table name is omitted, then it will show
locks on all tables.
I am using syslockinfo, spt_values tables and joining with SP_WHO procedure
to get the table name, user name and the session id.

Now what I need is to find out which SQL is causing the lock and since when
lock is being held on the table. Which tables in master database holds the
required information.

TIA.

Ravi

View 2 Replies


ADVERTISEMENT

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

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

Fun With Tracing

May 24, 2001

I would greatly appreciate any help with this problem, as I've been digging thru every resource I can find looking for a solution with no luck.

I'm going to be monitoring a database for all SQL statements containing INSERT, DELETE, or UPDATE. I'm grabbing the user name, time, and the entire text of the query. I can already do this programmatically, no problem. The problem lies in this. When I set up a trace on SQL Server 2000 using the system stored procedures sp_trace_create, sp_trace_setfilter, etc, and set the trace to save to a trace file, I find that I must first stop the trace then close the trace before I can use fn_trace_gettable to get the information that I want. However, this is undesirable, because this database may be accessed worldwide, and stopping the trace to read the data could cause the trace to miss some users making changes. Does anyone know how that I could get my trace data into a table so that I can just run queries on that table to get my data? It's very important that I not stop the trace to do this. Thanks for your help!
JR Rickerson
Software Engineer
Infinite Software Solutions, Inc.

View 3 Replies View Related

Tracing

May 20, 2008

What are different kind of traces we can take regarding the performace and how traces can be used for improving performance ?

spatle

View 5 Replies View Related

Tracing The Deadlock

Jul 12, 2006

Hi,
I need to trace deadlock, one of article was mentioning “QL Server Profiler's Create
Trace Wizard to run the "Identify The Cause of a Deadlock" for SQL Server 7.0, is there any way I can do this in Sql Server 2000?

View 1 Replies View Related

Tracing UDFs

Jun 6, 2006

How would I go about tracing UDF performance in profiler? I'd like to
specifically know the impact of the UDF without having to dig into the
execution plan of the statement containing it. Is this possible?

View 1 Replies View Related

Tracing Sql From Code

Jul 20, 2005

HiI want to trace all the selects/deletes/modifys whatever on a databasein an application that are performed in a seperate application.I need to look into this, any ideas?- Can triggers do this kind of thing- Can you somehow access the profiler via OLE or similiar to do this?- Anything else?TaF

View 5 Replies View Related

Tracing The Deadlock

Jul 12, 2006

Hi,
I need to trace deadlock, one of article was mentioning €œQL Server Profiler's Create
Trace Wizard to run the "Identify The Cause of a Deadlock" for SQL Server 7.0, is there any way I can do this in Sql Server 2000?

View 1 Replies View Related

Tracing The Sp_executesql

Oct 17, 2006

Hi,

I am using sp_executesql to get some data but it is not working. Is there a way to actually see the actual statement where subsituted variables are replaced with the actual values.

SET @SQLString = N'SELECT Top(1) @Passenger_OUT = Name, @Ticket_OUT = TicketNumber , @TAN_OUT= [TAN] '

+ N'FROM dbo.Table1 WHERE 1 = 1 '

+ Case @MatchAmount When 1 Then N' and Amount = @BillingAmount ' Else N'' End

+ Case @MatchTicket When 1 Then N' and LTrim(TicketNumber) = STUFF(STUFF(@TicketNumber,Len(@TicketNumber)-@RemoveRight+1,@RemoveRight,''''),1,@RemoveLeft,'''') ' Else N'' End

+ Case @DaysDiff When 0 Then N'' Else N' and DATEDIFF(d,@BillingDate , InvoiceDate) <= @DaysDiff ' End

+ Case @MatchName When 1 Then N' and Left(Name,@CharsToMatch) = Left(@PassengerName, @CharsToMatch) ' Else N'' End ;

SET @ParmDefinition = N'@BillingAmount decimal, @TicketNumber varchar(15), @RemoveRight tinyint, @RemoveLeft tinyint, @BillingDate datetime, @DaysDiff tinyint, @CharsToMatch tinyint, @PassengerName varchar(35), @Passenger_OUT varchar(35) OUTPUT, @Ticket_OUT varchar(15) OUTPUT, @TAN_OUT varchar(25) OUTPUT';

EXECUTE sp_executesql @SQLString, @ParmDefinition,@BillingAmount=@BillingAmount, @TicketNumber=@TicketNumber, @RemoveRight=@RemoveRight, @RemoveLeft=@RemoveLeft, @BillingDate=@BillingDate, @DaysDiff=@DaysDiff , @CharsToMatch=@CharsToMatch, @PassengerName=@PassengerName, @Passenger_OUT=@Passenger_new OUTPUT, @Ticket_OUT=@Ticket_new OUTPUT, @TAN_OUT=@TAN_new OUTPUT;

Print @SQLString will gives the statement with variables and I need to see the actual data plugged in during runtime.

If I take the ouput of @SQLString and run it myself by adding variables it works fine

Thanks

Shafiq

View 2 Replies View Related

Profiler Only Tracing One Server

Feb 4, 2002

There is a bug in one of the service packs where Profiler (7.0) only traces one server (regardless of the server you tell it to trace). Can anyone tell me how to fix this or point me to a KB article? I thought this was fixed in SQL 7 SP 3, however I'm experiencing this problem with SP3 installed.

View 1 Replies View Related

Tracing Failed Logins

Jul 19, 2001

SQL 7 profiler has an event in the Misc. category of Failed Login. It does not, or at least I cannot get it to, produce any output when a failed login occurs. Any hints?

I tried this because every week or so I get this in the error log:
Login failed for user 'Admin'.
It occurs several hundred times within a minute or so. It obviously has to be an automated process as you couldn't click a button or press a key 13 times a second.

The login does not exist as a SQL login so I can't tell which database it is trying to get at. Any suggestions gratefully received.

Simon

View 4 Replies View Related

SQL Server Error Tracing

Jan 24, 2000

Hi There,
I hope someone can assist me in tracing the cause of a problem I am experiencing. I have a Web Server with ASP's querying the SQL Server 6.50.416 database. There is only one user db on this machine and yet I am running out of User Connections (current setting 2000) and memory (128MB RAM). Also, NT repeatedly experiences Stack Dumps. I have used the PRINTDMP utility to try and trace the cause of the error. The "Input Buffer" section of the Stack Dump (symptom dump) contains the following:

SELECT FK_SUB_PRODUCT_GROUPING, FK_SUB_PRODUCT_NAME FROM RESOLUTION_PRODUCT_SUB_PRODUCT WHERE FK_PRODUCT_CODE=1072 order by FK_SUB_PRODUCT_GROUPING

Is this SQL Statement the cause of the Stack Dump? Does anyone have any other ideas on what may be causing my problem. Any help would be greatly appreciated.

View 1 Replies View Related

Tracing Or Debugging A Procedure

Dec 21, 2005

I have a very simple piece of code (see below) which when executed sometimes takes around 7 minutes and sometimes around 3.5 hours. the difference is that during the 3.5 hours there is a lot of querying of the table being updated. But I don't know how to find out if this is the case. How can I find out whether my process is waiting (for locks or for any other reason) - is there a trace or debug facility within the tandard Microsoft Toolset which I can use.

Regards
Colin

Problem code below
===============
print 'Updating stm_brnline - Start time is ' + convert(char(25),getdate(),113)
--
update m
set m.branchpgrade = s.branchgrade
from stm_brnline m, tmp_brngrades s
where m.traddiv = s.traddiv and
m.contcode = s.contcode and
m.merchsect = s.merchsect and
m.branch = s.branchcode
--
print 'Updating stm_brnline - End time is ' + convert(char(25),getdate(),113)

View 1 Replies View Related

Actual Syntax By Tracing

Feb 3, 2004

Hello


I am running 6.5 sql and work with a traffic and billing software ( called NOvar) from another company(encoda system) which does a lot of scheduling, reporting etc


I dont know the contents of table (100 table ) and their column
or which table its querying to take out reports


Can i create a trace to know the syntax each time some thing is executed.

I also need to create customized reports, can this be done by sql reporting or does i need to go from crystal reports or someone else
For i dont know any language except sql and HTML


sej

View 2 Replies View Related

Tracing Users Of A Database

Jun 13, 2007

Hi

As a newbie to DBA type tasks, how can I trace who has accessed the server/database. I know there is a SPID in the Server log but what does this represent?

Thanks!

View 6 Replies View Related

Tracing Query Time

Oct 5, 2007

I have a Stored Procedure that execute some queries on link server. It takes so long to complete so my application get timeout error. There was no problem until last week. I suspect, remote queries that qorks on link server takes long. How can i trace the time of queries. Any idea about link server timeout problems?

Thanks in advance.

View 2 Replies View Related

SQL Profiler And Single Client Tracing

Mar 10, 2000

I have a client which makes about 50 connections to my SQL Server using a non-unique username. Under SQL 6.5 I could trace all SQL activity by PC name, is this possible using the SQL Profiler in SQL 7?

Gordon

View 2 Replies View Related

Tracing The Actual Syntaz As Is Excuted

Jan 30, 2004

I am using 6.5 and on this i used different program
and people execute query

Can i place a trace to show what query is being executed from which program and at what time

Meaning the syntax of it and by whom



I start tracing and it paging file becomes to large


sej

View 3 Replies View Related

Question On Tracing Data Change

Jul 11, 2007

I have an issue where i have a field that changes data and i need to trace what it is that is changing it. I have setup a trace for the database but i would like to be able to narrow it down even further to the table and even the column if possible. Is there a way that i can trace data changes on such a granular level

View 1 Replies View Related

Tracing , History And Analyzing DTS Package

Nov 15, 2007

Hi guys,
We have 2 databases: DataBaseSource and DatabaseDestination. We need to truncate all the data in DatabaseDestination and put all the data from DataBaseSource into DatabaseDestination.

What is the best way to do that, we have a lot of data?
And what is the best way if we also need to keep a trace of what happened in case we wanna go back and see what happened.

Also , pls, if we use DTS, is it possible that if someone wants to see what the DTS does, is it possible to read the DTS? I mean if I give a dts to sompeone, a new DBA guy in 2 years for example, how can he know what a certain DTS does? I mean does SQL 2005 put the DTS packaege scripts somewhere or is there a friendly way to know what a DTS dsoes exactly?

Also the trace to see if something went bad is important for us?

Sory if i didn t express myself well enough, and thanks a lot for your help.

Rachid.

View 7 Replies View Related

Tracing Stored Procedure (SP) Usage

Jul 20, 2005

Hi,what I am trying to discern is if there is any way of logging SPactivity on a SQL server 2k DB. Ideally I would want to log SP name,parameters, user and time.I found sp_monitor in MSDN but that just gives overall statistics.Not specific enough to aid debugging.Thanks in advance,Finlay Macrae

View 1 Replies View Related

Optimizer Logic Tracing Tool

Jul 20, 2005

Guys,what I need is a tool which gives details on the choice of anexecution plan by the SQL Server. For example, the cost for a hashjoin might be 200 and 100 for a nested loop, and therefore a nestedloop is used. Same thing for the access paths for each table/viewinvolved. In Oracle, we turn on event 100053 to see this kind of info.ThanxDaniel

View 2 Replies View Related

Tracing HTTP/SOAP Endpoints

Mar 23, 2008

Has anyone worked out how to trace SOAP/HTTP Endpoints in SQL 2005 SP 2?

I'm not having a particular problem, just want to know how things work, such as which layer is responsible for the HTTP Authentication. I've traced the HTTP.sys stack using logman.exe (see http://www.thelastpickle.com/2008/03/22/tracing-sql-soap-endpoints-through-httpsys/) .

I cannot see any SQL Profiler events, and I've tried setting trace 7801 and 7803 as described in http://www.sqljunkies.com/Article/5CCAC423-1407-4A36-AF71-ED6A67D9646A.scuk#_Toc52964195 but they do not result in any logging.

thanks
Aaron

View 3 Replies View Related

Tracing Values In DTS Package/stored Procedure

Jul 20, 2005

Hello,I'm currently working on debugging a very large DTS package that wascreated by someone else for the purpose of importing data into mycompany's database. The data is mainly user/contact-related data forour customer base.We ran into problems when one import, of about 40,000 rows, tookupwards of six hours to complete. Many of the stored procedures usedby this package were written using XML. I've re-written many of themusing native SQL to see if that improves the performance, but I'mgetting some errors that I haven't been able to diagnose.Instead of asking about my specific errors, I'd like to know moregenerally what ways are there to debug DTS packages and storedprocedures? I'm aware of, and experienced with SQL Profiler but it'snot giving me the info I need. I need the ability to see exactly whatvalues are being passed to every call to a stored procedure fromwithin the DTS package or another stored procedure.I've used it very successfully to debug .asp, .aspx, .vb and the like,but right now I'm running it while running this huge stored procedurethat is called by the DTS package and does the lion's share of thework, including multiple updates and inserts into about 10 tables.The problem is, I see the calls to the "sub-procedures" from the mainone, but I can't see the values of any of the input or outputparameters. Instead ofInsert_Contact 'John', 'Q', 'Smith', '333-333-3333'......etc.I seeInsert_Contact @FirstName, @Initial, @LastName, @PhoneNumber......etc.My trace includes Stored Procedure events:RPC: CompletedRPC: StartingSP: StartingSP: StmtCompletedSP: StmtStartingand TSQL:Exec Prepared SQLPrepare SQLSQL: BatchCompletedSQL: StmtStartingI figured with these I would've covered the bases but I don't see anyof the parameters, which is critical for my debugging, as some of themare not being properly set.Any ideas or help would be greatly appreciated!TIA,Mike

View 4 Replies View Related

Tracing Insert, Update Or Delete For Entire Database

Jul 16, 1999

I need to create some kind of log file or table that will record whenever an insert, update or delete is made to any table in a database. I have seen triggers that do this kind of thing on a table level. Can this be done with a trigger or a stored procedure on a database level? If so some kind of example or syntax would be great.

TIA.

Mike

View 1 Replies View Related

DB Engine :: Event Tracing For Windows Failed To Send Event

Oct 25, 2011

My SQL Server 2005 SP4 on Windows 2008 R2 is flooded with the below errors:-

Date  10/25/2011 10:55:46 AM
Log  SQL Server (Current - 10/25/2011 10:55:00 AM)
Source  spid
Message
Event Tracing for Windows failed to send an event. Send failures with the same error code may not be reported in the future. Error ID: 0, Event class ID: 54, Cause: (null).
 
Is there a way I can trace it how it is coming? When I check input buffer for these ids, it looks like it is tracing everything. All the general application DMLs are coming in these spids.

View 2 Replies View Related

Locks

Nov 10, 2003

I have read that even during read procedures (sql select statements), sql server uses row locking. I know that you can use the NOLOCK keyword, but if you don't everytime that a user makes a selects statement on a table, does sql server really lock those rows, and if so are they then unavailable to another user who wants to make a select statement at the same time on that same table? That does not seem like it would be the case otherwise it would not scale well. Thanks for any clarification on this.

View 5 Replies View Related

Locks

Feb 13, 2002

I am using SQL Server7.0. I opened a table through the Enterprise Manager and left it open. In the Query Analyzer when I try to update a field on that table(more than 2000 rows), it goes on running. When I watched the Current Activity, it shows that the update process is being blocked by the select query. But if I try to update the same column for less than 1500 rows, there is no blocking issue and the update occurs immediately. Can anybody let me know why this is happening and what should I do to prevent it?

View 1 Replies View Related

Regarding Locks

Mar 28, 2000

I am using Sql Server 7.0

To I got the following error message. Can some one tell how to solve this issue.

Server: Msg 1204, Level 19, State 1, Procedure OPEN_OBJECTS, Line 2
SQL Server has run out of LOCKS. Rerun your statement when there are fewer active users, or ask the system administrator to reconfigure SQL Server with more LOCKS.

ranga.

View 1 Replies View Related

SQL Locks

Sep 26, 2000

what the best way to control locks, if inserting couple thousands records from one table to another.

View 5 Replies View Related

Locks

Feb 20, 2001

Hi
I have a big query which updates around 14000 rows at a time if i place a lock on the table and others try to update the same table is it possible to let them know that table is locked by someone else.

View 1 Replies View Related

Locks

Sep 19, 2002

2 quick questions :

1) How do I keep multiple users from editing the same record without locking the entire table? What would be a 'standard' way of handling this?

2) How do I keep 2 people from posting the same record?

Please help me understand locking, THANKS!!!

View 2 Replies View Related







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