SQL 2012 :: Deadlocks Between Application Queries And Replication?

Jul 10, 2014

We recently upgraded to sql server 2012. We have xxx-D-011 as OLTP server and yyy-D-011 as distributor server.

The log is showing deadlocks every day between application queries/updates and replication jobs.

A fragment of the log about the deadlock is included below.

2014-07-10 15:31:05.94 spid13s deadlock-list
2014-07-10 15:31:05.94 spid13s deadlock victim=process37ced3498
2014-07-10 15:31:05.94 spid13s process-list
2014-07-10 15:31:05.94 spid13s process id=process37ced3498 taskpriority=0 logused=0 waitresource=OBJECT: 8:532249001:0 waittime=357 ownerId=860304057 transactionname=SELECT lasttranstarted=2014-07-10T15:31:05.090

[code]....

View 9 Replies


ADVERTISEMENT

Analyzing Lock Order Of Queries Against Same Table To Prevent Deadlocks

Aug 5, 2014

I need to discover the actual order in which locks are acquired on a table during a query.

This with a goal of analyzing the lock order of queries against the same table to prevent deadlocks.

I'm using SQL Server 2008 R2.

From Management Studio I execute:

begin transaction
<my query>
exec sp_lock
rollback transaction

In the output I see interesting information about which locks are acquired, but:

- are this locks ordered by the time they're acquired? That is, can I be sure that lock at row n is acquired before lock at row n+1?
- if not, how can I get this information?

View 4 Replies View Related

Replication Deadlocks

Sep 16, 2005

Hi All,

View 15 Replies View Related

Snapshot Replication Deadlocks

Feb 4, 2004

Is there anyway to prevent deadlocks during the snapshot replication?

I understand that you can minimize by maybe creating a couple different snapshots (mixing tables to minimize locking while snapshot is being created), but is there any other way?

Thank you

View 1 Replies View Related

SQL2000 Replication Deadlocks

Jun 1, 2007

We have an SQL2000 database server that uses merge, pull replication with about 70 clients around the country, each with their own publication. Each article in each publication is row filtered by a single condition. There are busy times of the day when all of these clients attempt to replicate within a 15-20 minute period. We have noticed the following error that is creating conflicts that are resulting in data not being transferred to the server and very long replication run times (error message is paraphrased):



The record was inserted at the client, but could not be inserted at the server. Transaction (Process ID XXX) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.



Is there a way to lessen the effects of this error? How can I reduce the number of deadlocks that are occurring? We will need to be adding a great deal more clients to the system in the future; is there a way to grow the system without making the deadlock problem worse?



Any help will be appreciated!



Thanks,

Craig



View 1 Replies View Related

Replication :: Blocking And Deadlocks Are Occurring Continuously

Jul 2, 2015

We have transactional replication. After creating replication, we found that many blocking and deadlocks are occurring continuously. Will it cause any blocking on publisher db.

View 4 Replies View Related

SQL 2012 :: Deadlocks - Not Showing In Profiler

Feb 24, 2015

We have some Deadlock alerts set up in SQL Agent that email us when the performance counter for deadlocks goes above zero. I've used the following script to identify the event file which has deadlock information in there.

select CAST(target_data as xml) as TargetData
from sys.dm_xe_session_targets st
join sys.dm_xe_sessions s on s.address = st.event_session_address
where name = 'system_health'

Now that is fine, and we're looking into that (number of deadlocks appear to be 0.5) but out of interest ran a SQL Profiler session to capture the details as well and nothing is showing, I've received a few alerts and the trace file has information in there - but profiler shows absolutely nothing (all deadlock events are captured)

View 1 Replies View Related

SQL 2012 :: Deadlocks In Partitioned Tables?

Oct 31, 2015

We are using partitions and all the table are properly aligned as per the partition keys. When this particular sp, which is inserting data to a table from a different table based on the partitionkeys is called by Web UI where threading has been applied, dead lock appears.

Let me make it more clear.

ThreadOne:
Insert into table A(partitionKey,BatchId,...)
select * from table B where partitionkey = 1
ThreadTwo:
Insert into table A(partitionKey,BatchId,...)
select * from table B where partitionkey = 2

I can see sometimes it gives deadlock for this procedure, not sure about the reason, as far as I guess since the tables are partitioned and escalation is set to Auto the deadlock should not occur.

View 2 Replies View Related

SQL 2012 :: Mysterious Deadlocks On Heap Table

Jul 4, 2014

We have a highly transactional database. It was owned by a third party before but now both the database and the application is on our site and we are trying to improve this project. So, we have a big (902919 rows), heap table, which is getting bigger and bigger everyday and sometimes deadlocks occur. The table has only 4 columns, "token", "type", "value" and "cacheTime", unique index cannot be created. It has one index on "token"(char(36)) and "type"(varchar(50)) ("value" should also be included but it is nvarchar(max)).

<deadlock-list>
<deadlock victim="process670ba10c8">
<process-list>
<process id="process670ba10c8" taskpriority="0" logused="0" waitresource="RID: 6:1:14949918:1" waittime="417" ownerId="347523711" transactionname="SELECT" lasttranstarted="2014-07-01T17:43:35.233" XDES="0x117cf7da40"

[Code] ....

View 9 Replies View Related

SQL 2012 :: Facing Deadlocks During Updates On Heap Table

Mar 5, 2014

Facing deadlock issues in my ETL job .

The driver table , which keeps track of what datamarts ran and for what date range gets updated frequently during the etl run . There can be as many as 250 updates issued on this table in a single second.

Now this table is a heap , and there are no indexes on it .

During these updates , we encounter deadlocks causing the ETL job to fail .

Will adding an index faciltate?

View 4 Replies View Related

SQL 2012 :: Deadlock XDL File Remains Empty Even During Deadlocks

Mar 13, 2015

In order to troubleshoot some deadlocking that I am seeing on SQL Server, I am trying to capture the Deadlock XML by enabling the Events Extraction Settings option 'Save Deadlock XML events separately' and specifying a Deadlock XML results file.

Meanwhile, I am also tracing the Deadlock graph, Lock:Deadlock, and Lock:Deadlock Chain events. Yet the xdl file remains empty even though I am getting hits on the events themselves in the SQL Profiler trace.

Also, I have the following trace flag settings enabled.

TraceFlagStatusGlobalSession
1204110
1222110

Why the xdl file remains empty even though (I think) it should contain some XML for deadlocks that are actually happening?

View 4 Replies View Related

Capturing SQL Queries Of 3rd Party Application

Sep 15, 2003

Hello.

I would like to analyze how a particular 3rd party business application interacts with SQL server.

Specifically, I want to capture the "exact" SQL commands (transact-sql statements) that this application issues whenever it completes an operation for the user of this application.

In other words, suppose the application issues the SQL command "INSERT INTO table (a,b,c) values (1,2,3)" to add a new entry to the database. Then, my understanding is that if I instead issue the exact same command with a tool like "SQL query analyzer", the database will be updated in the exact same manner. Hence, I have effectively accomplished the same job that the 3rd party application does without even using it (by idependantly issuing the same command to the database it uses).

Is this possible? Can I obtain all the information I need just by running SQL Profiler?

View 3 Replies View Related

Application/Security Design: Stored Procedures Versus SQL Queries

Mar 7, 2007

Hello everyone,

I don't know what category would be appropriate for this question but security seems to be close enough.

I have this case scenario: I am running an automated application that extracts data from a web site and stores the data into a table on SQL server 2005. This information is not confidential in the extreme of social insurance #'s, bank account #s, but should not be seen by a typical employee (it has no use for them). After the data has been stored, it retrieves the data from the same table, processes it, and updates the same table. This application runs every hour infinitely.

Should all the insert, update, and select queries be stored under a stored procedure? I am not concern with performance. My concern would fall under design and security.

Is it worth to hide the details of inserting/updating/selecting behind a stored procedure? Or should I just allow the program to send select/update/insert SQL queries?

No employee (other then the developer and the DB admin) or customer ever access this table (They do not have permission from SQL). The username and passwords were created with security in mind.



Any thoughts or ideas?

Thanks for your time, Adrian

View 11 Replies View Related

Replication -Is Not A Valid Win32 Application.

Apr 22, 2002

Hi all,
I have a problem is that I cannot perform the transacional replication from one server (ms-sql2k) to other server (mssqlserver).

The error show below :
Log Reader Agent - Is not a valid win32 application.

I try to setup another server (mssql2k) to do the same thing, there is no error appeared.
Therefore, I have doubt that the name of the computer using "-" will have problem. Or the registry of (ms-sql2k) may have problem because it had wrongly installed personal edition and re-installed the standard verions afterwards.

Can anyone tell me the root of the problem ?

Simon

View 2 Replies View Related

SQL 2012 :: Incorporate Several Queries In 1

Dec 18, 2014

I am wondering if it is possible to make 1 query that gives several, different resultsets.

I am working on a database for speedskating times, in particular I am working on seasonlists

The query I use for this i (in simplified form)

SELECT LastName, FirstName, Country, Time
FROM TbExample
WHERE Distance = '500' and Gender = 'Man' My question is about the "WHERE Distance = '500' and Gender = 'Man' " part.

I need the combinations 500-Man, 1000-Man, 1500-Man, 500-Women, 1000-Women, 1500-Women.

In the current setup I need to make 6 queries.

Is it possible to make some kind of (as they call it in Excel) Array (or 2: 1 for distances, 1 for gender) that runs through all possible combinations?

View 9 Replies View Related

Replication Error -Is Not A Valid Win32 Application

Apr 22, 2002

Hi all,
I have a problem is that I cannot perform the transacional replication from one server (ms-sql2k) to other server (mssqlserver).

The error show below :
Log Reader Agent - Is not a valid win32 application.

I try to setup another server (mssql2k) to do the same thing, there is no error appeared.
Therefore, I have doubt that the name of the computer using "-" will have problem. Or the registry of (ms-sql2k) may have problem because it had wrongly installed personal edition and re-installed the standard verions afterwards.

Can anyone tell me the root of the problem?
Simon

View 1 Replies View Related

Scientific Application For Sharing Work - Replication?

May 15, 2006

Hi

I'm developing a scientific appliation - to forecast the spread of disease. The algorithm has been designed such that different subpopulations reside on separate computers.

The model uses the same set of data repeatedly, and only returns a small signature that reflects the appropriateness of a particular set of parameters.

The model does however change, and I'm looking for a way to roll out this model (which only contains T-SQL, CLR assemblies and service broker code).

I have considered setting up a database on each computer which has the 'data' files which are static, and a separate database which contains the algorithm which can be amended.

Could one then detach the algorithm database making the new version that can then be rolled out (by attaching it to each computer used)?

Is this the best practice? Does anyone have a suggestion as to how to do this?

Go well

Greg

View 1 Replies View Related

SQL 2012 :: Merge Two Queries To Have Only 1 Output?

Nov 2, 2015

We have two queries that run nightly and we'd like to combine them and only have one result set instead of two. What's the best way to combine these? The only difference is the Table the information is being pulled from.

Query 1:

set nocount on
select
case
when datalength(MICRACCTNUMBER) = 4 then convert(char(20),('001 000000000000'+MICRACCTNUMBER))
when datalength(MICRACCTNUMBER) = 5 then convert(char(20),('001 00000000000'+MICRACCTNUMBER))
when datalength(MICRACCTNUMBER) = 6 then convert(char(20),('001 0000000000'+MICRACCTNUMBER))

[code].....

Again, the only difference is the Table the info is coming from...

View 3 Replies View Related

SQL 2012 :: How To Trace For Parallel Queries

Nov 6, 2015

what the ideal CPU count and Max Degree of Parallelism are for a 3rd party database server.The server has 12 CPUs, 32GB RAM and all database sizes add up to < 30GB so they can all fit in memory (I tried to force this by doing a select * from every table). On certain payroll days, the CPU gets maxed out to 100% for a few seconds.

MAXDOP was originally set to the default 0. We later changed it to 8 based on several 'best-practices' articles. However the vendor suggests to change it to 1 (no parallelism), while others suggest changing it to 4, so that one run-away query doesn't hog most of the CPUs.

I'd like to find out how many CPUs are actually being used by queries. There is a Degree of Parallelism event in URL.... The BinaryData column says :

0x00000000, indicates a serial plan running in serial.
0x01000000, indicates a parallel plan running in serial.
>= 0x02000000 indicates a parallel plan running in parallel.- What does "parallel plan running in serial" mean ?

I see a lot of 0x01000000, and a few 0x08000000's in my trace.How can i determine whether one query is hogging CPUs and if reducing it to 4 will work?

View 4 Replies View Related

Application Locks Up When Trying To Write To Db After A Replication Where I Create The Database.

Jan 3, 2008

Hello all,

When I create a new database and replicate to it using BeginMonitoredBackgroundSync :







Code Block

public void BeginMonitoredBackgroundSync(string User)
{
CreateReplicationInstance(User);
repl.BeginSynchronize(
OnSimplifiedSynchronizeComplete,
SqlCeReplication_OnStartTableUpload,
SqlCeReplication_OnStartTableDownload,
SqlCeReplication_OnSynchronization,
repl);
}




private void CreateReplicationInstance(string User)
{
repl = new SqlCeReplication();
string host = repl.HostName;
repl.HostName = User;
string dbFilePath = "";


dbFilePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) +
"\" + repl.HostName + ".sdf";
string myConnectionString = string.Format("Data Source = {0};PWD = {1}", dbFilePath, sqlSettings.Items["SqlPassword"]);

repl.InternetUrl = dynamicsReplicationSettings.ReplicationSettingsItems["InternetUrl"];
repl.PublisherSecurityMode = SecurityType.DBAuthentication;
repl.Publisher = dynamicsReplicationSettings.ReplicationSettingsItems["Publisher"];
repl.PublisherDatabase = dynamicsReplicationSettings.ReplicationSettingsItems["PublisherDatabase"];
repl.PublisherLogin = dynamicsReplicationSettings.ReplicationSettingsItems["PublisherLogin"];
repl.PublisherPassword = dynamicsReplicationSettings.ReplicationSettingsItems["PublisherPassword"];
repl.Publication = dynamicsReplicationSettings.ReplicationSettingsItems["Publication"];

repl.Subscriber = "RemoteSubscription" + repl.HostName;
repl.SubscriberConnectionString = myConnectionString;

repl.ConnectionRetryTimeout = 120;
repl.LoginTimeout = 120;
repl.CompressionLevel = 6;

if (File.Exists(dbFilePath))
{
FileInfo info = new FileInfo(dbFilePath);
if (info.Length <= 20480)
{
File.Delete(dbFilePath);
repl.AddSubscription(System.Data.SqlServerCe.AddOption.CreateDatabase);
}
}
else
{
repl.AddSubscription(System.Data.SqlServerCe.AddOption.CreateDatabase);
}

primeConnection();

}
After the replication finishes, I dispose the replication object like so:





Code Block

void OnAsyncSynchronizeComplete(IAsyncResult asyncResult)
{

try
{
repl.EndSynchronize(asyncResult);
if (repl != null)
{
repl.Dispose();
repl = null;

}
if (ReplicationComplete != null) ReplicationComplete(this, true);
}
catch(Exception ex)
{
if (ReplicationComplete != null) ReplicationComplete(ex, false);
}

}

Then later, if I try to update, insert or delete to the database, the application will hang. I can read from it, but I cannot write. If I close the application down and open it back up without replicating, I will not get any lockups. It also will not hang up after any replications prior to the create replication. I think I am doing something wrong in the initial replication that is holding on to some connection to the DB causing it to lock up. Has anyone seen anything like this before?

View 1 Replies View Related

SQL 2012 :: Converting Access Queries To Views

May 13, 2014

Is there an easy way to convert Access Queries to SQL Views without doing it manually?I have used the Databse tool to migrate tables, but cannot see to find something similiar for queries.

View 3 Replies View Related

SQL 2012 :: Execute Multiple Queries And Email

Jul 14, 2014

I have to create a SQL job which will run around 50 queries and email results when the query gets some results.These are like quality checks which run to check errors in the system so if any query(out of 50 queries) returns some results an email with the details will be sent .So if 5 queries return results 5 emails with the details will be sent .

I think of something like A table which has one column as the query .What will be the best way of handling such a scenario , may be need an SSIS package with steps ?

View 3 Replies View Related

SQL 2012 :: Profiler - Trace Direct Queries Only?

Oct 21, 2015

Is there a way to setup a trace to show only direct TSQL statements triggered on my server? note I don't want to capture Procedure calls or the statements called within the procs.

Actually many people are firing direct SQL statements on server. And some are coming from entity framework as well. I just want to capture those.

View 1 Replies View Related

SQL 2012 :: How To Notify External Application

Sep 17, 2014

When my SQL Agent job completes successfully, I'd like to send a notification to QlikView. The idea is to stop QlikView having to constantly check if the job has been run, and just get notified when it needs to update its data.

I don't know how to start. Can the job notifications push a success message to QlikView? I don't think I want to send an email, but something that indicates to QlikView to update the tables.

View 3 Replies View Related

SQL Server 2012 :: Structure For Multiple Nested Queries

Feb 27, 2014

I am using Server 2012 and very new to SQL. I have a request from a physician for a list of his patients that meet a criteria. This is stored in a temp table names #cohort.

Using this cohort he wants each row to be one patient with a list of labs, vitals, etc. Three items are the most recent lab value and date. I could query each lab individually and place it into a temp table and then join all temp tables at the end, but I am trying to move past that and have all labs in one temp table. All temp tables are joined with PatientSID.

I tried to do something for just 2 labs, but it is not working. There could be nulls values when joined with the #cohort table.

Individually the SELECT statements pull in the most recent lab value and date, but I cannot get them into a temp table with one row of PatientSID and then the lab value and date if they exist.

IF OBJECT_ID ('TEMPDB..#lab') IS NOT NULL DROP TABLE #lab
SELECT
cohort.PatientSID
,SubQuery1.LabChemResultNumericValueAS 'A1c%'
,SubQuery1.LabChemCompleteDateTimeAS 'A1c% Date'
,SubQuery2.LabChemResultNumericValueAS 'LDL'

[Code] .....

View 1 Replies View Related

SQL 2012 :: Full-Text Queries Returning No Results

Jun 9, 2014

So I'm trying out full-text indexing for the first time and, in particular, FileTables in SQL Server 2012. I've followed a Microsoft walkthrough and everything seems to be ok. However, when I query the table using the CONTAINS keyword, I get no results (a regular query to make sure there are records in the table returns the expected number of results).

I'm now trying to troubleshoot, and have been using the FULLTEXTCATALOGPROPERTY function, but I don't understand the results.

If I run SELECT FULLTEXTCATALOGPROPERTY(N'CatlogName',N'ItemCount'), I get a result of 51. There are 96 documents in the NTFS folder where the documents are stored, and the table has 96 records, so I don't know where 51 is coming from. 55 of the documents are .DOC files, the rest are .PDF, and some (or maybe all) of the PDFs are scanned images of documents, which I don't expect to be indexed, so maybe that explains it. And in another thread in these forums, a poster suggests that the result for this function should be either 0 or 1, with 0 meaning that no documents are pending indexing, but maybe I've misunderstood that.

If I run SELECT FULLTEXTCATALOGPROPERTY(N'CatalogName',N'UniqueKeyCount'), I get a result of 2. I have got two full-text indexes in this catalog (one on the FileTable, one on a regular table with FT enabled). Is this result therefore expected? Again, reading online seems to suggest that a result of 0 is desirable, but I don't understand why, and if it is I don't understand why my result is 2!

I've now also run SELECT* FROM sys.dm_fts_index_keywords(DB_ID('DatabaseName'), Object_ID('dbo.FileTableName)), which I believe is supposed to list all of the indexed words from the table specified. I get one row returned, as follows:

keyword: 0xFF
display_term: END OF FILE
column_id: 2
document_count: 40

So basically, it's not indexed any words at all. And why is the document count only 40 when there are 96 documents in the folder and table?

View 2 Replies View Related

SQL 2012 :: How To Run Query Execution Plan For Parameterized Queries

Jul 21, 2014

know if there is any way out to run execution plan for parameterized queries?

As application is sending queries which are mostly parameterized in nature and values being used are very robust in nature, So i can not even make a guess.

View 1 Replies View Related

SQL 2012 :: Queries Based On ER Diagram And Joining Tables

Feb 22, 2015

I need to create a few select queries based on an er diagram.

These are my Create Table statements and import statements:

Create Table Agent (Aid integer primary key, Pid integer, aName text);
Create Table Product (Pid integer primary key, pName text);
Create Table Supplier (Sid integer primary key, sName text);
Create table Supplies (Sid integer, Pid integer, price decimal(8,2));

.import agent.txt Agent
.import product.txt Product
.import supplier.txt Supplier
.import supplies.txt Supplies

I think I got all my create table statements are correct.

I need to Find the number of agents for each supplier that has at least one agent. The result should be tuples of the form (sid, sName, number of agents)

-Select Sid, sName, count(Aid) from Agent A join Supplier S on (S.Sid = A.Sid) group by S.Sid, S.sName, Aid;
But it gives me this error: no such column: A.Sid

Im thinking I might have a problem with my create table statement and/or primary key statements?

View 9 Replies View Related

SQL Server 2012 :: Multiple Queries In Same Stored Procedure

Sep 16, 2015

Our developers have gotten this idea lately that instead of having many small stored procedures that do one thing and have small parameter lists that SQL can optimize query plans for, its better to put like 8-10 different queries in the same stored procedure.

They tend to look like this:

create procedure UberProc (@QueryId varchar(50))
as

if @QueryId = 'First Horrible Idea'
begin
select stuff from something
end
if @queryid = 'Second really bad idea'
begin
select otherstuff from somethingelse
end

I see the following problems with this practice:

1) SQL can't cache the query plan appropriately
2) They are harder to debug
3) They use these same sorts of things for not just gets, but also updates, with lots of optional NULLable parameters that are not properly handled to avoid parameter sniffing.

View 9 Replies View Related

SQL 2012 :: Hosting Application And DB Server On Same Machine

Apr 28, 2014

We have request where client want to host both application server(IIS...etc) and MSSQL DB server on same machine. (DB is used for Time & Attendance tracking only, so there are not many transactions per day and No HA) .........

Do we have any disadvantages if we host both on same Machine.?

View 1 Replies View Related

SQL 2012 :: Unable To Export Tables From GIS Application To The Database

Oct 1, 2014

I am using SQL server 2012. An user tried to export tables from GIS application to the SQL database.

After export, and login to the SQL server, we see all the tables has his name as the schema but not dbo.

He was added as a login and user as in a windows group. Meaning he is a member of the windows group.

I assume when export, the default schema should be dbo. but apparently not.
I went to the setting and explicitly make the default schema for the windows group user to dbo. But he tried again, it still use his username as schema prefix to the tables. just wondering why is this?

View 7 Replies View Related

SQL Server 2012 :: Return Multiple Messages To Client Application?

Jun 9, 2014

I have a procedure where after processing, i am required to send multiple message to calling application.

For ex:

create procedure test as
(@a as int,
@b as int
@c as int )
/*
some transformations */
print 'variable a is' + @a;
print 'variable b is' + @b;
print 'variable c is' + @c;

I am only providing a sample of return messages, but in reality there a lot more messages where a string and a parameter value need to concatenated.Unfortunately print is not allowing to concatenate parameter value.I can use RaiseError, but these messages are not really any error messages.

i tried to concatenate all message and output it using OUT type parameter, but the length of all messages combined exceeds 10000 characters.

Is there any other alternate to send these messages out to application?

View 1 Replies View Related

SQL Server 2012 :: Query For User Access To Application Modules

Mar 24, 2015

I have to create a query that will be returning the users and the application modules they have access for. Along with the list of users and modules the query should also return if any module is not accessible for that user.

The 'ApplicationUsers' table is like this:

CREATE TABLE #ApplicationUsers
(
userId INT,
UserName VARCHAR(50)
)
INSERT INTO #ApplicationUsers VALUES
(1, 'Daniel'), (2,'Martin'), (3, 'Brandon'), (4, 'Doug')The 'ApplicationModule' table is like this:

[Code] .....

I used pivot query but there are a couple of limitations in it(may be I am making mistakes in it). First, the pivot columns are static whereas I need dynamic column names(Application Modules). Second, I need to include all the users with all the modules with access or without access that I am unable to achieve.

View 5 Replies View Related







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