what are the best ways to action on the Deadlock issues. I am aware how a deadlock is occurred and we can get the queries causing by the Trace, and Profiler. What will en best steps to Investigate from DBA end later collecting the stats.What steps will ensure to get these deadlocks addressed.
Hello faculties,i'm encountering a strange a deadlock problem on my remote serverwhich is used to give application demo to the client. It has happenedthat on one of the databases a deadlock situation is taking place.What is the most detailed way to detect such the cause of such adeadlock to the innermost level of detail, like what statements, storedprocedures and locks are causing the deadlock to occur.Guys! please help me out!Thanks in advanceDebian*** Sent via Developersdex http://www.developersdex.com ***
Can€™t understand the Query execution interval, for every one criteria it takes extra 60 seconds. Help please?,
Query A
SELECT TOP 15 * FROM CMD4 AS T1 WHERE T1.ST IN
(SELECT max(T2.ST) FROM CMD4 AS T2 WHERE T1.SERIAL=T2.SERIAL
AND T2.sd='20060817') AND sd='20060817'
--AND STOCKNAME like 'A%'
ORDER BY D_CUM desc;
The above query take 2 seconds to return result
Query B
SELECT TOP 15 * FROM CMD4 AS T1 WHERE T1.ST IN
(SELECT max(T2.ST) FROM CMD4 AS T2 WHERE T1.SERIAL=T2.SERIAL
AND T2.sd='20060817') AND sd='20060817' AND STOCKNAME like 'A%' ORDER BY D_CUM desc
This query same as above but " AND STOCKNAME like 'A%'" Criteria only added but it takes 01 minute 43 seconds to return result. why it is like that where i need to adjust the query i have no idea. please help
Hi, I'm would like know if the analysis service data mining enables to detect anomalies from "normal" behavior/patterns of data (1), and alert about such anomalies when detected (2). both above sql server relational DB (3).
Hello ,I have a stored procedure that group a series of event by day. My table Tevent has a timestamp column for every event.Tevent structure:idevent| event| DatetimeEvent I just found out that I need to group the result by production shift of the day , therefore I have to group the result for everyday from 8 AM until 2 AM the next day.Any idea of how to group by time interval?Thanks
I'm trying to create a group by a set (but can change it later on) time interval. What I mean by this is the following. I would like to group my data by 5 second intervals, and perhaps have a count for it as well - but that's not required.
I have a table(work_order) with time as varchar(5).The values in table looks like thiswork_order_id rtim1 08:152 08:453 10:134 14:56and so on...I want to count how many work orders for every half an hour.The result should look like thisHours Count8 108:30 159 349:30 03and so on....really 8 hours means the work_orders issued (rtim)between 8:00 AND 8:30.Any Help is Appreciated.Thankyou.Jaidev Paruchuri
I need to add the Job Interval and Time to the following script:
SELECT DISTINCT 'CYP_BI' AS Server,Jobs.Name AS Job_Name, Jobs.description AS Alias, 'Enabled' = CASE (Jobs.enabled) WHEN 0 THEN 'No' WHEN 1 THEN 'Yes' ELSE '??' END,
[Code] .....
This query contains the job interval and time but when I add it to the first script I can't get my syntax right:
SELECT DISTINCT 'CYP_BI' AS Server, S.name AS JobName, S.description AS Alias, 'ScheduleName' = left(ss.name,25), 'Enabled' = CASE (S.enabled)
Time Interval for hour and 30 minutes --------------------------------------------------------------------------------
Hi Everyone
I Have column in sql server databas as "HHMMSS" and data as and i am doing a substring to get values for hours and minutes. since my calculations based on hour interval and 30 minutes interval
for ex: Now i want to show all the transaction done b/w 6 to 7 am or pn.
and for 30 minutes interval i have get the calculation as transactions done b/w 6:00 to 6:30 and 6:30 to 7:00 either it's am or pm. now how i can write my sql statements that calculates hour and 30 minutes intervals HHMM ------------- 06:43 09:26 09:26 11:58 12:25 18:17 20:45 00:43 00:53 16:47
So i tweaked a stored procedure that did a 1 hour update for a specific countryId.
If that procedure was called at the same time with two different countryId than one update took place and afterwards the other.
Since all the rows are distinct i switched to an batch update only updating 10000 rows at a time ( and not all of the 2 million).
The general locking looked better afterwards but now i receive strange deadlocks.
My theory:
TX1 Updates a row on Page1 (P1) with rowlock. TX2 also does this on P1. Now TX1 deceides to escalate to PAGELOCK. TX1 waits for TX2 to be done with the row so it can lock the page. TX2 waits for TX1 to leave the page since TX2 may also want to pagelock.
Everybody waits for each other so we have a deadlock. Is that feasible ? OR is there another common problem when doing batch updates on the same table with distinct rows ( that can be on a same datapage ofc).
I have a table (tbl_entries) in my db that has a timestamp field (startDate). What I need to do is run a query that counts the number of records on a 15 min interval.
something like
start_date 2008-01-01 00:00:00.000 2008-01-01 00:00:00.000 2008-01-01 00:00:00.000 2008-01-01 00:01:00.000 2008-01-01 00:01:00.000 2008-01-01 00:01:00.000 2008-01-01 00:14:00.000 EVERY THING ABOVE HERE IS IN GROUP 1 2008-01-01 00:35:00.000 EVERY THING ABOVE HERE IS IN GROUP 2 2008-01-01 01:01:00.000 2008-01-01 01:03:00.000 2008-01-01 01:03:00.000 2008-01-01 01:04:00.000 EVERY THING ABOVE HERE IS IN GROUP 3 2008-01-01 01:29:00.000 EVERY THING ABOVE HERE IS IN GROUP 4 2008-01-01 01:41:00.000 EVERY THING ABOVE HERE IS IN GROUP 5 2008-01-01 02:25:00.000 2008-01-01 02:28:00.000 2008-01-01 02:31:00.000 2008-01-01 02:33:00.000 EVERY THING ABOVE HERE IS IN GROUP 6 Hope this is enough Info
I want to check a record in my table which has time ins and time outs feilds. I want to check on insertionof any new record that a new record should not be inserted on same timings and before 45 mins of timein and after 45 mins of timeout. How do i do it sql query ?
I have a simple table as shown:  I want to have values on the last column to represent the time interval between the 2 date columns (visits); i.e for event-ID 2 for example, I will have
entry(EventID = 2) Â - exit(EventID = 1), and so on
hi there i am using .net framework 1.1 with SQL 2000 . i want the data in table to get deleted automatically after 30 days of inserting data. so how do i achieve this?
I have a column that is an int field and it holds the number of seconds that corresponds to a time during the day. Example being that 24331 will be 6:45:31 AM and 67531 will be 6:45:31 PM. I'm looking for code that will show the time in AM/PM format and with the AM and PM at the end of time.
I'm trying to create a report which will give me a break down of how many unique vehicles have been seen between two dates via a 15 minute interval and what Lane they were seen. My current script looks like this
SELECT l.Name [Name], count(l.Name) Total, p.Created FROM PlateReads p inner join Lanes l on p.Lane_ID = l.ID where LicencePlate in (Select Plate from LPRnet_MelAir_C.dbo.TempVehiclePlates) group by Name Name being the Lane they were in and the Total being the amount of times a unique vehicle has been seen and p.Created being the date they were seen (thats what I need the interval powered off)
Ideally the output would look like this
16/03/201408:00 to 08:15Bus Lane 15 16/03/201408:00 to 08:15Elevated Road150 16/03/201408:00 to 08:15Public Pickup75
16/03/201408:15 to 08:30Bus Lane 13 16/03/201408:15 to 08:30Elevated Road120 16/03/201408:15 to 08:30Public Pickup55
All the way to 12/04/2014
I’ve got it so it says Lane and Count just can’t get the interval part
i want to show data Party Name and Time interval wise. here is my table from where i will fetch data. so pasting table data here.
Call start Call duration Ring duration Direction Is_Internal Continuation Party1Name Park_Time ------------------------- ---------------- ------------- --------- ----------- ------------ --------------- ----------- 2015/06/08 08:06:08 00:02:28 2 I 0 0 Emily 0 2015/06/08 08:16:38 00:00:21 0 I 0 1 Line 2.0 0 2015/06/08 08:16:38 00:04:13 5 I 0 0 Jen 0
[code]...
now i am not being able to cross join this CTE with my table to get data party name wise and time interval wise. say for if no data exist for a specific time interval then it will show 0 but each party name should repeat for time interval 9:00:00 - 9:30:00 upto 17:30:00. i like to add what filter need to apply to get data for incoming, outgoing, call transfer and miss call.
For Incoming data calculation where direction='I' and Is_Internal=0 and continuation=0 and RIGHT(convert(varchar,[call duration]),8)<> '00:00:00' For outgoing data calculation
We ran into weird/interesting issue with below details.
Version:Â Microsoft SQL Server 2012 (SP1) - 11.0.3000.0 (X64)Â Standard Edition (64-bit) on Windows NT 6.2 <X64> (Build 9200):
We are using SQLCMD to run DDL script on our product database in below order. That script has below content.
step # 1 - database collation change (case -sensitive) statement as very first statement of the script step # 2 - Actual DDL SQL statements step # 3 - database collation change back to original (case insensitive)
When we execute all above 3 steps in single script using SQLCMD on our test_server#1 , it is successful but when same is being implemented on test_ server#2 , it is failing.We ensured that there is no other user accessing the db and setting on both the server are all default/basic. Separating out all 3 steps in 3 different script working fine. This is only problem when we combine them into single script and fire it using SQLCMD. If it is something related to session/transaction then we should hit same issue on our test_server#1 server as well but that is not the case.test_server#1 and test_server#2 has exact same database/data, just two different physical machine & SQL Server instance.
We know we can use the event lock_deadlock and xml_deadlock_report to capture the deadlock info, however I also want to capture the execution plans for all of the SPIDs in the deadlock graph, how to output the execution plans to the extended events trace results either ? such as if there is an action for execution plan or workaround for it ?If there is no built in action for execution plan , may I know if we can add the customized info to the extended events results file also ? Such as when the deadlock related event happens , then we can run a query to get some info ,then added the info along with other info such as sql_text, dbname etc  to the events trace results file either ? The reason is if we also know the execution plans when the deadlock happens, it is useful to turning the query based on the execution plans to reduce deadlock happening .
Implement time interval type in the form of a user defined type in SS2k8r2? Specifically an interval type described in the book Temporal Data and the Relational Model by C. J. Date at all. As an example, an interval is below:
1/4/2006:1/10/2006
which would mean the time period from 1/4 to 1/10.
Hi all.If I've got a query which has a field with seconds in it... how will I usethe Convert function to get my field converted to the format: HH:MM:SS ?The field with the seconds in is called: "Diff"Thanks alotRudi
SQL Server 2012R2 Express, I need to change db owner from Domain1User1 to Domain2User1.
Both SQL login Domain2User1 and db user Domain2User1 exist; db user Domain2User1 is mapped to SQL login Domain2User1.
When I try to change db owner from  Domain1User1 to Domain2User1
I get the error:
This article does not imply any restrictions on users that can be made db owners: [URL]....
"In SQL Server, the owner of the current database can be changed. Any user, a SQL Server login or Microsoft Windows user, who has access to connect to SQL Server can become the owner of a database."
Why can't I make the owner of a db an SQL login that have a mapped user in that db?
I have a problem upgrading a McAfee ePolicy Orchestrator which uses SQL Server 2008 R2 SP2. McAfee logs indicate that server names from SQL server and from McAfee installer does not match.It seems that the reason is that machine name was changed after SQL Server was installed.
MSDN instructions for sql server name changing give next commands to solve this problem: SELECT @@SERVERNAME AS 'Server Name'; sp_dropserver <old_nameinstancename>; GO sp_addserver <new_nameinstancename>, local; GO
But it didn't work for me, because "SELECT @@SERVERNAME AS 'Server Name'" shows correct (actual)Â name of sql server. So sp_dropserver says that there is now such instance.In the same time if I use this commands:
I am trying to change the default trace value from 2 to 6, to incorporate rollover and server shutdown. Â I am using this code to create a new trace (with id: 2) with the value of 6 and use that to overwrite the default trace (with id: 1):
  DECLARE @new_trace_id INT;   EXECUTE master.dbo.sp_trace_create    @someinteger = @new_trace_id OUTPUT,    @someinteger = 6,    @someinteger = N'C: raceTestTrace';
Then I disable the default trace. Â I am then using this code to overwrite the default trace (with id: 1) and replace with new value default trace (with id: 2):
    -- get trace status     SELECT * FROM ::fn_trace_getinfo(NULL)     -- stop trace     EXEC sp_trace_setstatus @traceid = 1           , @status = 0      go     -- delete trace     EXEC sp_trace_setstatus @traceid = 1           , @status = 2
Then I enable the default trace. Â It works perfectly (default trace with id 1 is showing value 6) until I restart. Â Upon restart no default traces are enabled, once I run the script to enable the default trace then the values for the default trace (with id: 1) are back, and my value for rollover/server restart is back to 2.
I want to move the log location to the E drive because it can get quite large. I already changed the setting in the SQL Server Error and Usage config tool, but this did not seem to make a difference.
I have a Stored Procedure that has a query in it and it take 0 second and then a stored procedure that takes 16 seconds. From what I can tell they shoul be the same.
It doesn't recompile when i run the stored procedure, I checked that.
We are experiencing authentication/ Kerberos issues after a password for the MSA's has changed. We use MSA for our SQL 2012 and windows 2012 combination Servers. This errors creates issues while backing up and Service Broker connectivity.We had to restart sql services to fix it, but this not seem to be a resolution for me because the next time the password changes on these MSA's we may have to restart sql services.There seems to be a known issue for windows 2008 R2 servers and fix is available and we incorporated it. But the issue we are facing is on windows 2012 Server.
We are developing an application that requires change tracking.We tested it in development and test environments and we are preparing our production deployment.The very first thing that needs to be done is an
ALTER DATABASE [db_name] SET CHANGE_TRACKING = ON (CHANGE_RETENTION = 2 DAYS, AUTO_CLEANUP = ON)
We are holding on this first step because this statement alone executed for a good 4min on the development server. The production environment is many times larger and busier, and we can’t afford service disruption, so we are at the point where we need to understand what’s involved in running this ALTER DATABASE statement.Is there any documentation on what is happening behind the scene when this statement executes such that we can assess the risks of running it in production?