SQL 2012 :: Mystery Of Transactions Older Than Their Sessions
Mar 8, 2015
So I've been monitoring long-running transactions on a SQL Server that hosts a couple of vendor-supplied databases that look after our factory.Today I noticed a pair that have confused my Excel spreadsheet (that I've been using to analyze these transactions).So here's the weird thing that I spotted. Given this query:
SELECT p.spid, p.login_time, at.transaction_begin_time, datediff(second, p.login_time, at.transaction_begin_time) as [difference]
FROM sys.sysprocesses AS p INNER JOIN
sys.dm_tran_session_transactions AS st ON st.session_id = p.spid INNER JOIN
sys.dm_tran_active_transactions AS at ON st.transaction_id = at.transaction_id
[code]....
I had a look in the event log on the server, which had just been rebooted at around that time. It seems that the clock got changed on boot-up, with the size of it quite surprising. This meant that these processes were able to start their transactions *before* they logged on. Hopefully this doesn't cause any other weird problems.So I've requested an investigation about time synchronization on our virtualization hosts... and in the mean time, have set the SQL Server services to 'delayed start'.
View 0 Replies
ADVERTISEMENT
Aug 18, 2015
I have a table which has XML data, so it takes lot of time to delete it.
Here's the condition:
Archive all data older than 2 months and delete it.
What would be the good approach for this?
View 3 Replies
View Related
Jul 15, 2015
We have SQL Server 2012 EE SP2 server that is getting hit by reports that time-to-time use up to 300GB of tempdb.
It's happening because our clients can use 'bad' parameters for some reports.
Is there a way to autokill sessions that overuse tempdb (for example, if a session uses more than 15Gb in tempdb)?
Killing can happen immediately or after regular check (5 min for example).
View 3 Replies
View Related
Nov 11, 2014
I need only the count of databases that last fullbackup was older then 24 hours or null. and status is online. I have tried
SELECT Count(DISTINCT msdb.dbo.backupset.database_name)
From msdb.dbo.backupset
where datediff(day,backup_finish_date,GETDATE()) > 1 -- or is null
and Database_Name not in ('tempdb','ReportServerTempDB','AdventureWorksDW','AdventureWorks') --online also
group by Database_name, backup_finish_date
Tried using where max(backup_finish_date) < datediff(day,backup_finish_date,GETDATE()) .But get the aggregate in where clause error. get a count of databases with backups older than 24 hours not including the samples, report service, and tempdb. I would also want to put status is online but havent gotten the above to work so havent tried to add that yet.
View 2 Replies
View Related
Feb 20, 2014
I want to implement a script which will run continuously to find out blocked sessions and send an email when ever it finds the blocking.
View 5 Replies
View Related
Jan 22, 2015
I have a table with the following columns employeeSessionID, OpDate, OpHour, sessionStartTime, sessionCloseTime. I need to see how many users remain active per hour. I can calculate how many logged in per hour, but I am stumped on how to count how many are active per hour. I have a single table that stores login data. I have created a query that pulls out the only the data needed from the table into a temp table using this query. Also note it is possible that the sessionCloseTime is null if the device has not been logged out this would need to be counted a active.
TABLE NAME #empSessionLog Contains the time stamp data OpDate, sessionStartTime and sessionCloseTime.
OpDatesessionStartTimesessionCloseTime
2015-01-202015-01-20 14:32:59.1302015-01-20 14:33:14.6299166
2015-01-202015-01-20 06:58:33.7302015-01-20 15:27:16.9133442
2015-01-202015-01-20 09:56:22.8402015-01-20 17:56:29.7555853
2015-01-202015-01-20 05:59:18.6132015-01-20 14:05:19.0426707
[code]....
can see how many sessions logged in per hour with the following statement:
SELECT
opDate,
FORMAT(DATEPART(HOUR, sessionStartTime), '00') AS opHour,
Count(*) AS Total
FROM #empSessionLog
Group BY opDate, FORMAT(DATEPART(HOUR, sessionStartTime), '00')
Order BY opDate, FORMAT(DATEPART(HOUR, sessionStartTime), '00') ASCResults:
opDateopHourTotal
2015-01-20041
[code]....
Where I am stuck is how do I count the sessions that remain active per hour until the session is closed with the sessionCloseTime.
View 5 Replies
View Related
Mar 24, 2015
In an instance with 2008R2, the value of Transactions/sec in Master DB is very bigger than an instance with 2012.
Is it normal? I ask it because both instances execute the same application with the normals differences between them (the Transactions/sec's number for the application's bds is similar).
View 0 Replies
View Related
Apr 25, 2014
how many transactions per second transactional replication can handle?
Server has 128GB RAM, 12 core 2 Process (24 core total) each transaction is approximately 32k.
Publisher and Subscriber are on different servers on same LAN, separate disks for logs, data, indexes and tempDB.
I've found data on how many transactions per second SQL Server can handle but nothing on replication.
View 1 Replies
View Related
Apr 22, 2014
I have a update trigger. In this trigger I need to insert few records in 3 tables. If error comes in any of these inserts then previous inserts to get committed. This trigger was written in Sybase and it was possible to create transaction and commit the transactions.
View 4 Replies
View Related
Mar 5, 2015
I vaguely remember reading somewhere that all distributed transactions are executed at Serializable Isolation Level "under the covers."
1. Is this true?
2. What does "under the covers" mean in this case; i.e. will I not see the isolation level represented accurately in requests?
View 9 Replies
View Related
May 14, 2015
It is my understanding that when having LinkedServers, the option "enable promotion of Distributed Transactions for RPC" should be set to TRUE, so we can rollback , if needed, remote transactions. At least, that's my understanding of that setting.
Having said that, the TRUE setting is affecting this particular TSQL code, inside an sproc, which I would prefer not to alter:
Insert into #TempTable
EXEC ServerB.MyDatabase.MyStoreProcedure
@param1= '',
@param2= ''
When set is set to TRUE (current setting) I get this error:
OLE DB provider "SQLNCLI11" for linked server "ServerB" returned message "The partner transaction manager has disabled its support for remote/network transactions.".
Msg 7391, Level 16, State 2, Line 28
The operation could not be performed because OLE DB provider "SQLNCLI11" for linked server "ServerB" was unable to begin a distributed transaction.
... when set to off, the error goes away.
View 8 Replies
View Related
May 22, 2005
Hi there,
I have decided to move all my transaction handling from asp.net to stored procedures in a SQL Server 2000 database. I know the database is capable of rolling back the transactions just like myTransaction.Rollback() in asp.net. But what about exceptions? In asp.net, I am used to doing the following:
<code>Try 'execute commands myTransaction.Commit()Catch ex As Exception Response.Write(ex.Message) myTransaction.Rollback()End Try</code>Will the database inform me of any exceptions (and their messages)? Do I need to put anything explicit in my stored procedure other than rollback transaction?
Any help is greatly appreciated
View 3 Replies
View Related
Mar 4, 1999
I have a table Catalog_Item with 365000 rows. I wish to move the contents of the table to an identical database on a different server using bcp. The table has no primary keys, foreign keys, or indexes. I am able to successfully bcp out the data in character format and native format.
I attempt to bcp the data in to the identical table on the other server, but
the bcp ALWAYS fails at 19000 or 20000 rows; it does not complete, just hangs there in the command window, with no more info. When I use a small data set of 5000 rows, the same happens at the end of those 5000. I have tried to redo the bcp in native mode, and character mode. I have tried to specify the first line starts at 125000. I have tried to bcp the data into a different database on a different server; that also quits at 19000 or 20000 rows.
BCP of other large data sets into the same database occurs smoothly. Only this combination of table and data set is giving this problem.
any ideas?
View 2 Replies
View Related
Apr 13, 2005
I am having trouble connecting to an SQL Server from an ASP.NET page
written in C#. I have reduced the code in my page to this: public void Page_Load( object s, EventArgs e ) {
SqlConnection conn = new SqlConnection( "Server=server;User ID=user;Password=pass;" );
conn.Open();
} and I get the following error:
System.Data.SqlClient.SqlException: SQL Server does not exist or access denied.
This
works for other server/user/pass except the one I am having trouble
with. The SQL Server is using SQL & Windows Authentication. I am
able to connect from the machine that is running the webserver via
osql, ODBC, and MS Access using the same arguments (server, user, and
pass), so I know that the SQL server does exist, and the User/Password
should give me access. Does anyone have any ideas why this
isn't working or what ASP.NET is does differently from the other access
methods? Any ideas are greatly appreciated. Thanks, Mark Dane
View 6 Replies
View Related
Jan 31, 2000
I have created a maintenance plan which backups to a device which I have created. However the device does not show in explorer and maintenance plan cannot find it when it trys to open the device. Consequently I'm not getting a backup.
Even if I delete the device and re create it things don't change.
Running SQL 7 SP1 on NT SP5 with SMS 2 SP1.
Any help gratefully received....
Dave Turner
View 1 Replies
View Related
Jan 28, 2000
I was working at a customer site and wanted to verify that backups were indeed being run successfully before I began to make changes.
I noticed a dump device for the production database with the nightly backup in it but I cannot find the task that produces this dump. I did find the task that dumps the log each hour.
Is there another area that some of you DBAs used to schedule dumps other than the task manager that I might be missing? Maybe an AT job?
Thanks.
-Darin.
View 1 Replies
View Related
Feb 3, 2000
I am trying to track down an account in SQL 6.5 that keeps showing up in my failed login log. We are using Standard Security.
The log doesn't provide much detail other than the attempted login name and the time/date.
Any ideas on how to track down more information on this mystery account would be appreciated.
Thanks.
Darin Drewrey
View 2 Replies
View Related
Jul 20, 2005
Hi all,I have a statement that reads as follows:select [Sales Ledger] - gl as differencefrom(SELECT SUM(RPAAP / 100) AS [Sales Ledger] FROM F03B11) Q1join(SELECT SUM(GBAPYC + GBAN01 + GBAN02 + GBAN03 + GBAN04 + GBAN05 +GBAN06+ GBAN07 + GBAN08 + GBAN09 + GBAN10 + GBAN11 + GBAN12)/100AS GLFROM F0902WHERE (GBAID = '00667809') AND (GBFY = 3)) Q2My first nested statement however I keep getting the message:Server: Msg 170, Level 15, State 1, Line 8Line 8: Incorrect syntax near 'Q2'.I just cannot fathom why this is so?Any suggestions would be most helpful.Moby*** Sent via Developersdex http://www.developersdex.com ***Don't just participate in USENET...get rewarded for it!
View 1 Replies
View Related
Jul 17, 2007
Hey All,
Hope this is the right place for this post.
I set up logshipping between two databases recently. everything looks fine. the backup, copy and restore jobs are all suceeding(from the job log). the problem is no Tlogs are being restored in secondary database. The restore job skips all the tlogs and says it did not find any tlog back up file to restore!! The jobs finishes with this:
007-07-17 14:40:30.59 Could not find a log backup file that could be applied to secondary database 'SaaSNet_dataStore'.2007-07-17 14:40:30.59 The restore operation was successful. Secondary Database: 'SaaSNet_dataStore', Number of log backup files restored: 02007-07-17 14:40:30.59 Deleting old log backup files. Primary Database: 'SaaSNet_DataStore'2007-07-17 14:40:30.59 The restore operation was successful. Secondary ID: '5808a414-2ada-41d2-a8a0-2cf84f85174a'
Appreciate your help
View 3 Replies
View Related
Sep 8, 2007
I have an old Compaq Presario walmart pc. The stats on it are: 750MHz Duron, 512MB RAM, currently have 20GB and 30GB hard drives and planning on upgrading HD (100GB+), onboard nvidia vanta (8mb tnt2). If I get a larger hard drive, XP Pro, and put SQL Server Express on this computer, would I be able to get things done, or will this be extremely slowed down?
Thanks,
Nate
View 1 Replies
View Related
Aug 17, 2004
In general, patch management solutions use an approach very similar to inventory and deployment, although, obviously, implementation details vary. Inventory relies on an external database to establish what is considered to be a recommended patch level and provides criteria for validating whether a particular patch has been installed. Products from Microsoft and Shavlik Technologies (on which HFNetChk, MBSA, and SMS 2.0 Feature Pack are based), keep track of published patches on the Microsoft Web site using the same mechanism, based on an XML formatted file called mssecure.xml. This file, available centrally at predefined locations, serves as a template against which the status of updates on target systems is compared. mssecure.xml can be obtained directly or via its compressed, digitally signed version, mssecure.cab. Both files can be downloaded from:
the Microsoft Web site at https://www.microsoft.com/technet/security/search/mssecure.xml and http://download.microsoft.com/download/xml/security/1.0/nt5/en-us/mssecure.cab
the Shavlik.com Web site at https://xml.shavlik.com/mssecure.xml and http://xml.shavlik.com/mssecure.cab
View 1 Replies
View Related
Sep 6, 2007
Calling any OLAP Guru's. Were attempting to improve a vendors BI process which involves running MDX queries against our SSAS cube, then saves the data into their own proprietary database which is taking to long.
We currently run this process on a x16 CPU, 65GB top end server attached to expensive disk subsystem, however a dual-core processor
laptop completely out performs the expensive hardware by around 45% quicker. Both when the configuration is identical or when we ramp up the processes on the expensive hardware it still performs miserably compared to the laptop. Perfmon counters or Profiler don't so much difference when comparing the server and laptop.
Does anyone know why the laptop completely outstrips the expensive top end hardware perfmance wise although the configuration profile is identical?
View 3 Replies
View Related
Jan 18, 2008
Hi all,
I found problem with my database and was wondering if anyone here could shed some light on the issue.
I have two tables, Absences and AbsenceDates. The first one records the absence of an employee and the second one records a record for each day of the occurance. I do a full select on the second table and I see primary keys that do NOT exist in the select of the second table. so I dug further and here is what I found.
Select * from Absences (rowcount in Query Analyser is: 20883)
Select * from Absences Order By AbsenceID Desc (rowcount is 443)
The second select contains the data that I am missing in the first select. So, I called a friend and they said to run DBCC CHECKDB and I did. The data came back as follows...
DBCC results for 'Absences '.
There are 21337 rows in 243 pages for object 'Absences'.
CHECKDB found 0 allocation errors and 0 consistency errors in database 'EmployeeAbsenteeism'.
DBCC execution completed. If DBCC printed error messages, contact your system administrator.
now if you add up the rows that the other two selects return it comes to 21326, not 21337. I am assuming that the value that DBCC gets is from sysobjects and that some sort of update would need to be run for it be accurate. This I don't care about too much, what I really need is for my main select statement to return ALL of the data, not just what it feels like returning.
My experience is with programming mainly (6 years in .net) and not DBA, so any help would be greatly appreciated.
Cheers,
Brent
Sorry, this was supposed to go to data corruption forum... reposting..
You should check out www.hogwarts.tv ...
View 3 Replies
View Related
Jul 23, 2005
I'm currently running Profiler sessions to track down Lock Timeoutproblems.My Profiler view contains (amongst others) the dbid column.Much of the time, this displays familiar dbids, such as 2 (tempdb) and5 (my main user db). However, it also regularly displays IDs of 0 and132.Using SELECT DB_NAME(), these translate as "master" and "NULL"respectively.Does anyone know:a) why dbid = 0 translates to "master", when the actual id of thisdatabase is 1, andb) why Profiler reports these dbids in the first place?
View 3 Replies
View Related
Jul 23, 2005
I have encountred situations like this before, but this onehas me stumped.I have a pretty simple SP that collects information aboutresidential properties from a large database. First step is toquery on the basis of address or location, and collect a temptable of property IDs. Second step is to populate a compositetable of property information by joining the IDs to a table ofcharacterisitics. Third step is to update some fields by findinga single value from multiple candidates in large tables -- onehas 275 million, another 325 million rows -- e.g., the price ofthe most recent sale for a property.As an SP, this takes absolutely forever, and it seems it's doingendless scans of the large tables. So to analyze it, I took thecode and ran it as a script -- turned the parameter definition atthe top into a DECLARE statement, set values for the variablesthat are the input parameters, no other changes, and go. Presto!It runs in no time flat, and the query plans reveal it's usingthe indexes just like it's supposed to. But the SP might takean hour to do the same thing.Any suggestions about what to look for? I believe both versionshave fresh query plans -- I have recompiled (and dropped andrecreated) the SP, and the plain script should have a fresh plan.Maybe it's because the parameter values are known when the scriptruns, but not when the SP is complied? I would really appreciateany pointers, and can provide more information as needed.Thanks,Jim Geissman
View 6 Replies
View Related
Jul 20, 2005
CREATE TABLE [dbo].[LOG]([TYPE] [smallint] NULL ,[TIME_STAMP] [datetime],[ID] [varchar] (44))ID is non-unique. I want to select all IDs where the last entry forthat ID is of type 11.Below is the query that I used. Notice that the subquery used is anested (not correlated) subquery meaning that it doesn't use resultsof outer query. This subquery should only be executed once. However,on large number of rows (3 million), this query never returns.I have also attempted to run subquery separately. That takes 1 minute.Then I put the results in temp table and joined that temp table withthe main query. That takes about 2 minutes.Unfortunately, that solution is unacceptable to us since we have tosupport both MSSQL and Oracle with the same queries, and the syntaxfor temp tables or table variables is different in Oracle.Mysterious.Here's the query:-- main queryselect IDfrom logwhere ID in(-- subqueryselect id from log l1where time_stamp =(select max(time_stamp)from log l2where l2.id = l1.idand l2.type = 11))
View 2 Replies
View Related
May 31, 2006
I was hoping someone could shed some light on wierd situation i'm experiencing. I have the following query:
select count(*) LeadCount
from auto_leads al
where received > dbo.GetDay(GetDate())
dbo.GetDay simply returns a smalldatetime value of today's date.
Now I recently got thrown into a data mess and for some reason this query takes 8 seconds to run. Now the first thing I did was update the stats on the Received column of this auto_leads table. I re-run the query and I'm still getting 8 seconds. I look at the execution plan I can make figure out why this is happening.
I then change the above query so the filter received > dbo.GetDay(GetDate()) is now just received > '5/31/2006' and the query comes back immediately. This doesn't make sense to me because the GetDay function is really simple and comes back immediately. I then try the following query to confirm it isn't a problem with the GetDay function:
declare @Today DateTime
set @Today = dbo.getday(GetDate())
select count(*) leads
from auto_leads al
join type_lead_status tls on (tls.type_lead_status_id = al.type_lead_status_id)
where received > @Today
Sure enough, the query came back immediately. Next thing to go through my mind is that the query execution plan has been cached by SQL Server using the execution plan from before I updated the stats on the received column. So I executed sp_recompile 'auto_leads' and tryed the original query again. Still taking 8-10 seconds to come back.
So my question, is why when I remove the GetDay function call in my query filter is the query slow, as opposed to me just passing a variable into the query? Thanks!
- James
View 6 Replies
View Related
Feb 8, 2008
I have a varchar field with leading alpha, plus 1 or 2 numerics, like 'A2' or 'A20'
And yet,
select cast(substring(T2.ALPHANUM_CODE, 2, 4) as numeric)
from ...
where ...
/* and substring(T2.ALPHANUM_CODE,2,1) not like '[0-9]' */
/* and substring(T2.ALPHANUM_CODE,3,1) not like '[0-9]' */
/* and substring(T2.ALPHANUM_CODE,4,1) not like '[0-9]' */
/* and substring(T2.ALPHANUM_CODE,5,1) not like '[0-9]' */
this generates a cast as numeric conversion error in my result set.
However, if I supplement my query with each of the commented WHERE clause add-ons in turn, I get 4 zero-record result sets.
So, how can I have nothing but digits 0 thru 9 in each of 4 positions, but the cast as numeric attempt of those 4 character positions as a string fails?
Any thoughts?
Thanks ...
View 6 Replies
View Related
Oct 4, 2007
I am trying to format a background color based on the field's value. But the expression always returns the false result.
Here is the expression I am using
=iif(Me.Value="RSB","Red","Blue")
I have also tried
=iif(ReportItems("Type").Value="RSB","Red","Blue")
Both fill the background color blue when the textbox clearly contains RSB. I'm not sure why it cannot find the value. The field data type is Char(4). The textbox values are all uppercase.
This all started when I was trying to use a report parameter for conditional formatting and I realized that it wasn't working. I broke down the expression by directly trying a value.
Any thoughts?
View 4 Replies
View Related
Jul 30, 2006
Hi,
Here is my code on how i connect to my database
Dim rst As New ADODB.Recordset Dim conn As New ADODB.Connection Dim vresponse As String ' On Error GoTo err_proc Try conn.Open(GetConn(getconnid)) Select Case getmode Case 0 'execute then return first field rst = conn.Execute(getsql) If rst.EOF = False And rst.BOF = False Then Try vresponse = IIf(IsDBNull(rst.Fields.Item(0).Value), "", rst.Fields.Item(0).Value) ' vresponse = rst.Fields.Count Catch ex As Exception vresponse = "Error :" + ex.Message End Try End If Case 1 'execute only If bTransactional = True Then conn.BeginTrans() End If conn.Execute(getsql) vresponse = "OK" If bTransactional = True Then conn.CommitTrans() End If End Select
Return vresponse.Trim
* line 1)
rst = Nothing conn = Nothing
Exit Function
supposed to be *line 1) terminates the connection/session form SQL server. But when i check to the SQL Query Analyzer, there is still some connections related to this command. So when i run again this commands, it creates another connection. How can i terminate/end my sessions in SQL.
Thanks
View 1 Replies
View Related
Jan 12, 2000
Hi all!
First of all, thanks to those who gave me suggestions to use sql-dmo
to generate sql scripts of a database.
I've found it extremely useful!
Here's my new problem.
I have VB code that connects to a database, extracts the schema
and generates the sql.
After some work with this script, I have some new scripts to alter the database and I have tried running these scripts in a separate project
with the ExecuteImmediate method of the Database object, which works well.
However, when I put this code into the first project, to reconnect to the database and execute the batch command,
I get SQL-DMO error -2147199229 (80045203)
...whatever that means..
Can anyone help me?
Thanks
View 1 Replies
View Related
Feb 27, 2008
Hi Friends,
We need a small suggestion regarding releasing the resources utilized before closing the session we established with the SQL CE database. To the best of our knowledge we are releasing the resources properly but still some how some resources get locked and we were not able to open a new session after closing the existing session.
Are there any functions or methods available to identify the existing resources, rowsets and other components who have connection with the existing session, kindly help us in this regard since we struck up mainly with this issue.
We work with EVC++ 3.0 and SQL CE 2.0
Thanks in advance.
Regards,
Sasi.
View 2 Replies
View Related
Jun 15, 2015
I have a piece of code that has happily run daily for at least 4 years. I have moved it to a machine that is meant to have an identical set-up, and it fails. I need to work out why it fails, but I am stuck. The code works as follows:
CREATE storedProc1 (Parameter1, etc)
DECLARE @TransactionName nvarchar(127), @TransactionActive bit
-- Plus Other Variables...
BEGIN
BEGIN TRY
SET @TransactionName= 'TransactionName1'
SET @TransactionActive = 'True'
BEGIN TRANSACTION @TransactionName WITH MARK
[Code] .....
When I EXECute StoredProc1, it fails with the Error Message "Cannot roll back . No transaction or savepoint of that name was found." I think that message comes from a ROLLBACK TRANSACTION statement in the CATCH of StoredProc2. I have tried commenting out that ROLLBACK statement, which changes the error message to: "Transaction count after EXECUTE indicates a mismatching number of BEGIN and COMMIT statements. Previous count = 1, current count = 2."
View 3 Replies
View Related