TSQL for capture and insert to a user table when blcoking is happening on a SQL server
Hi,
I am searching for a TSQL which will capture the blocking script to a table with execution plan and all other necessaryu details. I tried with below script but its not giving the text for blocked statement
I t will be nice if i get RequestingText and BlockingTest
SELECT @@servername as Instancename,getdate() as [date],session_id,start_time,status,command,database_id,blocking_session_id,
wait_type,wait_time,last_wait_type,ST.TEXT AS SQL,
wait_resource,open_transaction_count,cpu_time,total_elapsed_time,reads,writes,logical_reads,text_size from sys.dm_exec_requests SR
CROSS APPLY SYS.DM_EXEC_SQL_TEXT(SR.SQL_HANDLE) AS ST
where blocking_session_id >0
I tried the below link also, this this script also got blocked
http://blog.sqlauthority.com/2010/10/06/sql-server-quickest-way-to-identify-blocking-query-and-resolution-dirty-solution/
But when you run select * from sys.sysprocesses where blocked >0
i can see blocking
and it will be nice if I get RequestingText and BlockingTest
in the user table
You can get the requesting text for the spid that is blocked, plus all the other information you get from sys.sysprocesses by
select SUBSTRING(st1.text, (p.stmt_start/2)+1,
((CASE p.stmt_end
WHEN -1 THEN DATALENGTH(st1.text)
ELSE p.stmt_end
END - p.stmt_start)/2) + 1) AS RequestingText,
p.*
from sys.sysprocesses p
CROSS APPLY sys.dm_exec_sql_text(p.sql_handle) AS st1
where p.blocked <> 0;
But you will not bee able to get the command that caused the lock that is causing the blocking. SQL does not keep that information. For a lock, it only keeps the spid that owns it, what is locked, and the kind of lock. It does not keep
the command that caused the lock. And while you can, at least sometimes get the last command the blocking spid has issued, but that may well not be the command that caused the lock. The command that caused the lock might be anything the blocking
spid ran since it entered transaction state. And since that could be the last command or many, many commands ago, you won't be able to get that information with a query into the system tables and/or views.
Tom
Similar Messages
-
Can BO Enterprize SDK inserts records into user table
From Infostore can we create a jsp script using Java SDK to inserts records into user table??
Thanks
AmarHi Amar,
I want to retrieve data/records from Infostore and insert into a user table using JSP script. Is it possible to do this?
Infostore is a database used by BO Server. so any changes made in infostore through BO enterprise session is valid.
Say u want to retrive on of report present in folder <my folder>.
The you have to query for that. for eg.
boinfostore.query("select * from ci_infoobjects where si_kind ='report' and si_foldername='my folder'");
Create/add/insert any new information in infostore is done by functionalities provide by SDK.
like adding the user or scheduling a report will add new object to infostore.
If you directly access cms database and make any changes then , I am afraid you will end up with nightmare.
So it is always recommneded to access infostore/ cms database only from bo session.
For more information refer below link
[http://devlibrary.businessobjects.com/BusinessObjectsXIR2SP2/en/devsuite.htm]
then under Contents
BusinessObjects Enterprise SDK >> COM developer guide and API reference >> Query Language Reference
do revert if any queries
Thanks,
Praveen. -
Statement for Lock and Unlock an Oracle user (Urgent)
Hi DBAs.
I just want to know about the statement used for lock and unlock the Oracle user thru sysdba suer.
Thanks
HassanHey,
SQL> alter user <USERNAME> account lock;
and
SQL> alter user <USERNAME> account unlock;
Cheers,
Marcello M.
Sorry Justin, same answer........
Message was edited by:
Marcello M. -
TS1702 On my Page Tool Bar I don't get the icons for info and insert. Please help
When I open my Pages Program I don't get the icons for 'info' and 'insert'. Please help
I'm having the exact same issue. Any help is appreciated!
Thanks! -
Can I use a Bluetooth headphone/microphone for capture sound instead of normal iPhone mic when shooting video?
The sound when I record video is not so good, so I'm trying to use the Bluetooth headphone/microphone to capture a person voice but not know which setting to use.Hi Robert
Thanks for answering. I didn't know where to post other than the bluetooth forum which is relatively quiet and had no answers forthcoming.
Yes the voice isn't reaching the amp although it is registering on the input bar in the Sound System Prefs, just won't "play through" as it were. I can't see how it could be done I was just hoping someone might see something I am missing.
It seems a shame that you can't do it as iTunes on an old iBook makes a good juke box for DJ'ing and with everything becoming wireless these days it seems sensible that you could cut that one last wire.
Mike -
How can i open a DOC or TXT file and insert the data into table?
How can i open a DOC or TXT file and insert the data into table?
I have a doc file . the doc include some columns and some rows.(for example 'ID,Name,Date,...').
I'd like open DOC file and I'd like insert them into the table with same columns.
Thanks.Use the SQL*Loader utility or the UTL_FILE package.
-
XML PARASE and insert /update in corresponding tables
Hi,
I have a XML in which master details tables 3 tables.I want to separate element and insert/update in corresponding tables dynamically.
Table invlovled in A,B,C
Thanks
ReenaReena
The easiest way to do this is along the following lines..
(1) register an XML Schema that describes the XML you wish to process with theh database.
(2). create a relational view for the top level elements and for each repeating element (element where maxOccurs > 1 in the XML Schema)
(3) Use 'insert as select' or other SQL type processing to update your relational tables from the contents of the view
It is normally recommended that you add the following annotations to the XML Schema before registering it with the database
(1) At the schema level set xdb:storeVarrayAsTable="true".
(2) At the complexType level set xdb:maintainDOM="fasle".
If you search the forum you will find a lot of examples of creating relational views of XML content stored in the XML database. Typically these examples will include key words like 'create or replace view' and 'table(xmlsequence(extract' or 'xmltable'.
Hope this helps...
-Mark -
Hi
how to create a external content type for Read and Update data from two tables in sqlserver using sharepoint designer 2010
i created a bcs service using centraladministration site
i have two tables in sqlserver
1)Employee
-empno
-firstname
-lastname
2)EmpDepartment
-empno
-deptno
-location
i want to just create a list to display employee details from two tables
empid firstname deptno location
and same time update in two tables
adilWhen I try to create an external content type based on a view (AdventureWorks2012.vSalesPerson) - I can display the data in an external list. When I attempt to edit it, I get an error:
External List fails when attached to a SQL view
Sorry, something went wrong
Failed to update a list item for this external list based on the Entity (External Content Type) 'SalesForce' in EntityNamespace 'http://xxxxxxxx'. Details: The query against the database caused an error.
I can edit the view in SQL Manager, so it seems strange that it fails.
Any advice would be greatly GREATLY appreciated.
Thanks,
Randy -
reminders app--how do i access alarms for it and tell me to buy milk when i gtet to store
I thought your answer to my question would help me, but when I tried it none of the questions came to me. even the + sign doesn't work.
I tapped on an existing reminder....remind me did not appear so I could tap it...nothing happened at all.
I guess I need another answer from your knowledge base (YOUR BRAIN)
thanks very much,, sorry to bother you -
How many users from an application can connect to a SQL server at a time?
HI,
I need to know , How many users from an application can connect to a SQL server at a time? Do we have any settings for this in SQL server for limiting the users?This is a difficult question, since it is both technical and legal.
The absolute maximum number of connections is around 32700, but unless your server is very beefy, it will choke long before that. A connection is not a user - an application can have many connections for the same user. Depending on your license
model, you may be legally limited to a certain number of users, but this number is not enforced technially.
Erland Sommarskog, SQL Server MVP, [email protected] -
Using Cursor and FOR LOOP to INSERT the data into table
Hi all,
I have SELECT statement that returns 3 rows:
PROCESSNAME
PROTDATE
IMM
2013-12-18
Metrology
2013-11-18
CT
2013-12-04
SELECT processName, MAX(NVL(protStartDate, protCreateDate)) AS protDate
FROM TABLE(SEM_MATCH("{
?ipc rdf:type s:Protocol .
?ipc s:protocolNumber ?protNum .
?ipc s:protocolCreateDate ?protCreateDate .
OPTIONAL {?ipc s:protocolSchedStartDate ?protStartDate }
?ipra rdf:type s:ProcessAggregate .
?ipra s:hasProtocol ?iprot .
?iprot s:protocolNumber ?protNum .
?ipra s:processAggregateProcess ?processName.
}",sem_models("PROTS", "LINEARS"),NULL, SEM_ALIASES(SEM_ALIAS("","http://VISION/Data/SEMANTIC#"),SEM_ALIAS("s","http://VISION/DataSource/SEMANTIC#")),NULL))
Group by processName
Now I need to INSERT these values into the table along with the other values.
these other values come from different table.
INSERT INTO MODEL_CLASS_COUNTS (MODEL_NAME, CLASS_NAME, INS_COUNT, COUNT_DATETIME, PROCESS_NAME, PROT_DATE)
VALUES
("$MODEL",
"${i}",
(SELECT COUNT (DISTINCT S) FROM TABLE(SEM_MATCH(
"{?s rdf:type :${i} . }",SEM_Models("$MODEL"),NULL, SEM_ALIASES(SEM_ALIAS("","http://VISION/DataSource/SEMANTIC#")),NULL))),
SYSTIMESTAMP, %%here need to insert PROCESSNAME, PROTDATE%%
t was giving me error:
PL/SQL: ORA-22905: cannot access rows from a non-nested table item
so i enclosed sparql query into single quotes.
The code is as follows:
declare
type c_type is REF CURSOR;
cur c_type;
v_process varchar2(200);
v_pdate varchar2(200);
begin
open cur for
' SELECT processName, MAX(NVL(protStartDate, protCreateDate)) AS protDate <-- it's complaining about this being too long identifier, i think...
FROM TABLE
(SEM_MATCH (
?ipc rdf:type s:Protocol .
?ipc s:protocolNumber ?protNum .
?ipc s:protocolCreateDate ?protCreateDate .
OPTIONAL {?ipc s:protocolSchedStartDate ?protStartDate }
?ipra rdf:type s:ProcessAggregate .
?ipra s:hasProtocol ?iprot .
?iprot s:protocolNumber ?protNum .
?ipra s:processAggregateProcess ?processName.
}",SEM_Models("XCOMPASS", "XPROCESS"),NULL,
SEM_ALIASES(SEM_ALIAS("","http://VISION/Data/SEMANTIC#"),
SEM_ALIAS("s", "http://VISION/DataSource/SEMANTIC#")),NULL))
Group by processName';
loop
fetch cur into v_process, v_pdate;
exit when cur%NOTFOUND;
--here I need to insert v_process , v_pdate into my table along with other values...
dbms_output.put_line('values for process and prod_date are: ' || v_process || v_pdate );
end loop;
close cur;
end;
exit;
Now, I get an error:
ORA-00972: identifier is too long
Does anyone know way around this?Hi,
I tested something similar with insert into select and it worked fine :
insert into t_countries(ID,CITY ,POPULATION, DESCRIPTION, located, insdate )
SELECT 1 id, city, o , city||' is a nice city' description, max(nvl(locatedAt,'unknown')) as located,
SYSTIMESTAMP
FROM TABLE(SEM_MATCH(
'{GRAPH :gCH {<http://www.semwebtech.org/mondial/10/countries/CH/> :hasCity ?cityID .
?cityID :name ?city .
OPTIONAL{?cityID :locatedAt ?locatedAt .}
?cityID :population ?o .
SEM_Models('VIRT_MODEL_MONDIAL'),
SEM_Rulebases(null),
SEM_ALIASES(SEM_ALIAS('','http://www.semwebtech.org/mondial/10/meta#'),
SEM_ALIAS('prv','http://www.semwebtech.org/mondial/10/countries/CH/provinces/')
null))
group by city,o
order by city;
Or with execute immediate :
declare
v_country varchar2(200) :='http://www.semwebtech.org/mondial/10/countries/F/';
v_text varchar2(2000);
begin
v_text := 'insert into t_countries(ID,CITY ,POPULATION, DESCRIPTION, located, insdate )
SELECT 1 id, city, o , city||'' is a nice city'' description, max(nvl(locatedAt,''unknown'')) as located,
SYSTIMESTAMP
FROM TABLE(SEM_MATCH(
''{<'||v_country||'> :hasCity ?cityID .
?cityID :name ?city .
OPTIONAL{?cityID :locatedAt ?locatedAt .}
?cityID :population ?o .
SEM_Models(''VIRT_MODEL_MONDIAL''),
SEM_Rulebases(null),
SEM_ALIASES(SEM_ALIAS('''',''http://www.semwebtech.org/mondial/10/meta#'') ),
null))
group by city,o
order by city';
dbms_output.put_line(v_text);
delete from t_countries;
execute immediate v_text ;
commit;
end;
Marc -
RE: Pbm in alv for copying and inserting the record....
Hi,
I am developing alv gird report...............what my issue is:
while selecting a record...........he should copy the record and insert a new record
below on which he selected....
Regarding this if anybody helps me that will be appreciable...
Regards,
Naveen M.hai Do like This:
at user command
FORM PICK USING COMMAND LIKE SY-UCOMM SELFIELD TYPE SLIS_SELFIELD. "Pick is name given in REUSE_ALV_GRID
READ TABLE idata INTO wa_data INDEX SELFIELD-TABINDEX.
CASE COMMAND.
WHEN '&IC1'.
Select second data according to your requirement in Another internal table.
newdata[] = idata[]. "Move ur first table display data to one new internal tabe.
clear idata[].
append wa_data to idata.
now move data which was selected in select statement to idata table and append data. "it will add new data in idata table
after this get previous data in idata
READ TABLE newdata INTO wa_data INDEX SELFIELD-TABINDEX.
clear wa_data.
modify newdata index sy-tabix.
delete newdata where "it is initial.
loop at newdata.
idata = newdata.
append idata.
endloop.
after this call reuse_alv_grid_display.
endcase
endform. -
IIt was in my mind to load office then transfer. After to load paralels and transfer my windows system. I have a new copy of office for Mac plus paralels PC to Mac transfer version 8. As this is my first mac (I have ipads and iphones) I am unsure of what to do. Also to confuse matters I use a windows laptop as my sync machine for the phones and ipads (i do have a cloud account with backup) can I transfer both machines to my new imac? I will have a 1tb fusion drive + 2tb time capsule although I only have less than 400GB of data on both machines. Hope this is not too confusing for everyone but I am looking forward to sorting this mess out by just using the one machine.
Use the Office for Mac and ignore using Parallels for that. If you have PC only apps you have to run that are MS Windows only then consider Parallels. Just transfer your main PC, using Migration Assistant. If you don't know how then simply read over Pondini's article called Lion or Mountain Lion Setup Assistant tips and look for the section on migrating from a PC. Millions have done what you are about to, it's far from leading edge these days, if you go to an Apple Store to purchase they will offer this as a service, something you might be interested in.
-
HOW CAN I ADD/UPDATE/INSERT IN A USER TABLE WITH MATRIX
Hi All,
I have one User table (Defined as No Object) and what i need to do is a form with a matrix to Add/Update/Delete data in my user table.
I already create the form and the matrix that already give me the user table data. But now i have several problems to solve.
First I try to add a new row but this new row get the data of the last row in the matrix. What i needed is a blank row to add new data in the user table.
Second, when i change data in matrix and do update in the form, sap show me the message that the operation is successfully done but the data in the user table in not updated.
I am trying to do one forma like whe can find in Setup-> General -> Freight.
Can anyone help me?
Best Regards,
Luis DuarteHi,
If ur dealing with a simple form like that U can as well use the direct table form, and just provide a FMS to auto matically fill the code and name. U can directly use the form by.. Tools-->UserDefined Windows
Or
Comming to ur problem.... when ur adding a new row clear the data sources so that u'll get a blank row.
And for update the best thing to do is delete all the records in the table and again insert all the records directly from the matrix.
Hope it helps,
Vasu Natari. -
How to parse XML Column and insert values into a table
Hello,
I am working on a simple project to demonstrate how to load and extract XML using SQL, I have already made a table that contains a column of XMLTYPE and loaded an XML file into it (code below)
create or replace directory XMLSRC as 'C:\XMLSRC';
drop table Inventory;
create table Inventory(Inv XMLTYPE);
INSERT INTO Inventory VALUES (XMLTYPE(bfilename('XMLSRC', 'Inventory.xml'),nls_charset_id('AL32UTF')));
select * from Inventory;
I now however need to get the XML data back out of that and loaded into a new table. Troubleshooting guides I have read online seem to only be dealing with parsing an external XML document and loading it into a table, and not what I need to do which is parse a column of XML data and load that into a table. The project trivial with simple tables containing only 3 columns.
The table that needs to be loaded is as follows:
create table InventoryOut(PartNumber Number(10), QTY Number(10), WhLocation varchar2(500));
The XML document is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<dataroot xmlns:od="urn:schemas-microsoft-com:officedata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Inventory.xsd" generated="2012-04-09T17:36:30">
<Inventory>
<PartNumber>101</PartNumber>
<QTY>12</QTY>
<WhLocation>WA</WhLocation>
</Inventory>
</dataroot>
Thank you for any help you can offer.First of all, thank you for your help!! Still stunned that you actually took the time to write out an eample using my tables/names/etc. Thank you!!
Attached is the code, there seems to be an issue with referencing the other table, Inventory.Inv, I checked and that table and the Inv column are showing up in the database so I am not sure why it is having issues locating them, take a look at the code I wrote as well as the output (*I included the real version number for you this time :)
EDIT: In your code right here:
select xt.*
3 from Inventory inve,
4 XMLTable('/dataroot/Inventory'
5 PASSING inve.Inv
I think is where I am messing it up, perhaps not understanding fully what is going on, as you write "Inventory inve" and "inve.Inv" ---- Is inve a keyword that I am just not familiar with? I think this is where the issues lies in my code.
END EDIT
EDIT2: Well that looks like it was it, changed that to how you have it and it now works!!! Could you please explain what that few lines is doing, and what the xt.* and inve are doing? Thanks again!!!
END EDIT2
drop table InventoryOut;
create table InventoryOut (PartNumber number(10), QTY number(10), WhLocation varchar2(500));
insert into InventoryOut (PartNumber, QTY, WhLocation)
select xt.*
from Inventory Inv,
XMLTable('/dataroot/Inventory'
PASSING Inventory.Inv COLUMNS
PartNumber number path 'PartNumber',
QTY number path 'QTY',
WhLocation path 'WhLocation')xt;
select * from InventoryOut;
select * from v$version;
table INVENTORYOUT dropped.
table INVENTORYOUT created.
Error starting at line 4 in command:
insert into InventoryOut (PartNumber, QTY, WhLocation)
select xt.*
from Inventory Inv,
XMLTable('/dataroot/Inventory'
PASSING Inventory.Inv COLUMNS
PartNumber number path 'PartNumber',
QTY number path 'QTY',
WhLocation path 'WhLocation')xt
Error at Command Line:8 Column:12
Error report:
SQL Error: ORA-00904: "INVENTORY"."INV": invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
PARTNUMBER QTY WHLOCATION
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
If this helps here is the code and output for the creation of the Inventory table itself:
create or replace directory XMLSRC as 'C:\XMLSRC';
drop table Inventory;
create table Inventory(Inv XMLTYPE);
INSERT INTO Inventory VALUES (XMLTYPE(bfilename('XMLSRC', 'Inventory.xml'),nls_charset_id('AL32UTF')));
select * from Inventory;
directory XMLSRC created.
table INVENTORY dropped.
table INVENTORY created.
1 rows inserted.
INV
<?xml version="1.0" encoding="WINDOWS-1252"?>
<dataroot xmlns:od="urn:schemas-microsoft-com:officedata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Inventory.xsd" generated="2012-04-09T17:36:30">
<Inventory>
<PartNumber>101</PartNumber>
<QTY>12</QTY>
<WhLocation>WA</WhLocation>
</Inventory>
</dataroot>
Thanks again for your help so far! Hope we can get this working :)
Edited by: 926502 on Apr 11, 2012 2:47 PM
Edited by: 926502 on Apr 11, 2012 2:49 PM
Edited by: 926502 on Apr 11, 2012 2:54 PM
Edited by: 926502 on Apr 11, 2012 2:54 PM
Updated issue to solved - Edited by: 926502 on Apr 11, 2012 2:55 PM
Maybe you are looking for
-
I have 18 iMacs on a Windows Active Directory network. At the end of the last school year I could control and manage all 17 (one new one this summer). This year I can only control 8 of the 18. The other 10 say either: Offline, Sleeping, or Access Den
-
Is it possible AT ALL to make fglrx work with the ATI RV505?!
I have an ATI X1550 graphics card based on the chipset in the topic subject... I wish my PC wasn't half-height, so I could go get a real graphics card.... but I have what I have for now, and I guess I should settle for it. So, the problem in question
-
Check box in SAP Query selection screen
I want to keep 2 check box in SAP Query selection screen. could you please tell me any one. regards, kumar
-
How do i get rid of the white boot-up
I've been having dificulties on getting into my desktop some how it just stays on the white screen with the apple logo and it dosent move from there and the computer gets really hot, and beacuse im student i need to get my work from there ASAP. PLEAS
-
HT201260 What do I do if I can't afford to spend money on a new system to move to i-cloud?
I need Lion to move to mobile me which I am told is the only option. I rely on my emails to work and am self employed.