Performance Problems Updating A Remote Database Using Triggers
Apr 20, 2005
I have a table that has triggers on insert update and delete. The triggers perform modifications on another table on a remote databased(linked server).
All triggers make a join between the tables inserted, deleted and the remote table.
When running a profile on the remote database it seems that the following query is done on the remote table by the triggers.
"Select * from Database.dbo.Table"
The triggers are the only entities accessing the remote table from the original server so the query must come from them. My only conclusion is that MSSQL server is doing this query for some kind of "optimization".
Has anyone seen this before?
How can I work arond this? The remote table is BIG and this query happening every few seconds in a problem for me.
Thanks
Robert
View 4 Replies
ADVERTISEMENT
Apr 12, 2008
I have a SqlExpress DB on my server. I have a remote copy for security/backup reasons. Because the DB file(and .bak file) is about 2 Gb, it take a while to copy the whole thing to the remote machine. I believe there is a way to use the log file to simply update my remote copy ratherr than copying whole files, but I don't know what this process is called to research it. I have Brust's book on Sql Programming, but I have not found what I am looking for in there. Can anyone tell me where I should be looking and what this process is called?
thanks,
Steve
View 8 Replies
View Related
Mar 25, 2004
How would i update a field with a triggers to set the column password to something else if the password column = <NULL> on a update.
thank you very much.
View 3 Replies
View Related
Feb 21, 2000
Can anyone tell me what is the performance degradation if I use triggers to implement referential integrity instead of
foreign key constraints.
Thanks in advance
Samson
View 1 Replies
View Related
Oct 12, 2015
I have table A and B. A has column ID,A1,A2,A3,A4,A5 columns. B has ID,B1,B2, A1 columns. A table has a trigger. I defined the below trigger.Â
Solution 1
ALTER TRIGGER [dbo].[Tri_A]
ON [dbo].[A]
for UPDATE
AS
BEGIN
  UPDATE B
 SET B.A1= i.A1
 FROM inserted i
    INNER JOIN BÂ
    ON B.ID = i.ID
END;
GO
If I change the above solution 1 trigger to solution 2.Can I improve the trigger performance dramatically? I mean only A.A1 is changed then update B.A1. So when the other columns is changed, the update will not be required.
Solution 2
ALTER TRIGGER [dbo].[Tri_A]
ON [dbo].[A]
for UPDATE
AS
BEGIN
IF ( UPDATE (A1) )
  UPDATE B
 SET B.A1= i.A1
 FROM inserted i
    INNER JOIN BÂ
    ON B.ID = i.ID
END;
GO
View 2 Replies
View Related
Apr 25, 2008
Hello all, quick question and then a little background.
Could someone point me in the right direction when it comes to updating remotely deployed instances of a SQL CE database? I don't expect someone to code my project for me, but I'm getting lost in the sea of information and haven't found anything that looks like what we need yet.
What's going on is that I was given the wonderful opportunity to learn SQL.NET programming from the other side of application development. I'm not a beginner programmer by any means, but kind of a newbie when it this level of SQL deployment. What we are trying to do is give our users applications that use a local instance of the larger SQL database we have on the server. We were thinking that deploying SQL CE databases created from the master DB would be a good solution since it is supposed to have updating capabilities, which would be wonderful since then the users wouldn't have to be burdened by having to manually download and update a huge database install file every time we updated the information in the master.
What I'm finding though (after going throught the tutorials), is that the RDA feature (this would only need a pull function) that we were hoping to use requires that you delete the entire table, and then replace. If the master DB has only a few record changes in several scattered tables, it seem that this operation would be similar in size and resource demands as just re-downloading the entire database again (~2.7 gigabytes and growing).
Is there a function that can use a feature on the field properties that can download and replace only those fields/records that have changed intead of basically replacing the entire database?
Sorry if this seems like a painfully obvious question, but I have been looking for a while and haven't been able to find it.
thanks a ton in advance!
Brian
View 4 Replies
View Related
Jun 10, 2004
Hello everyone.
I'm currently trying to figure out a good way to keep my Local and Remote Databases in sync. Whenever I make changes to one or the other I spend a lot of time manually adjusting the other to match. I want to be able to set up an update page that accesses my Remote database and Local database and Updates the two accordingly.
I really don't know where to start with this one. I'm not sure at all as to how to simultaneously connect to two different databases, on two different servers, and Udate from one another. Does anyone know any good articles to get me started?
Thanks ahead for your replies.
-Alec
View 1 Replies
View Related
May 25, 2008
Greetings all
Have another issue with OPENDATASOURCE
The following SQL appears to run successfully:
Update OPENDATASOURCE('SQLOLEDB','Data Source=10.10.10.171;User ID=*****;Password=******').TRANSFERSTN.TSADMIN.SALESDAY
set STARTDTTM = L.STARTDTTM,ENDDTTM = L.ENDDTTM,CLOSED = L.CLOSED,
CASHEDUP = L.CASHEDUP,CASHINTILL = L.CASHINTILL,CHEQUESINTILL = L.CHEQUESINTILL,
EPSALES = L.EPSALES,EPCUTORETURN = L.EPCUTORETURN,REPFLAG = R.REPFLAG
from OPENDATASOURCE('SQLOLEDB','Data Source=10.10.10.171;User ID=******;Password=*****').TRANSFERSTN.TSADMIN.SALESDAY AS R inner join
TSADMIN.SALESDAY as L on R.SALESDAYID = L.SALESDAYID where L.REPFLAG = 1
However, all records in the remote table get updated if there are any records satisfying the REPFLAG clause, if more than 1 then I guess the last record in the source set.
Running the same SQL against 2 tables in the local DB works perfectly.
These are both MSDE V8.00.2039 SP4 connecting via RAS dial up.
Any ideas where to focus my attention will be gratefully received
Thanks
<EDIT>
Haven't solved the issue, but staggered around it. I have simply reversed the tables in the SQL and executed at the remote server instead, so it is updating a local table while getting data from a remote table. This functions as it should. Any clues to the above would still be good tho' - cheers
<END EDIT>
View 2 Replies
View Related
Oct 19, 2007
Hi folks,
Environment:
We change from SQL Server CE 2.0 to SQL Server CE 3.0, and we got our customer complaining about the performance lost in the process that makes 50 updates in the Pocket PC with windows mobile 5.0.
Our customer says that when they used the SQL Server CE 2.0 the process was quicker.
Process:
We need to do an update to 50 rows every time we lose the focus. Those 50 update are creating a deterioration of performance.
There is any Patch to add to SQL Server CE 3.0? There is any problem updating 50 times on a row losing performance?
Thanks in advance.
View 1 Replies
View Related
May 21, 2008
Hi everyone
I have a Stored Procedure mySP that updates a table in a linked server.
The same table is also being updated by other processes in the remote server
Usually mySP updates 10-20 records at a time, and that works fine.
BEGIN TRANSACTION
......
......
UPDATE [REMOTE_SERVER].[DB].dbo.[REMOTE_TABLE] SET VALUE = 2
WHERE ID IN (SELECT ID FROM LOCAL_TABLE)
COMMIT
The problem begins when mySP tries to update 100+ records, it gets a time out probably due to locking issues
(indexes are properly set in both remote and local tables )
I read some articles where they suggest to break the transaction in several batches of a smaller size to avoid locking issues.
Something like:
BEGIN TRANSACTION
.....
.....
DECLARE @Rows int
DECLARE @Batchsize int
SET @Batchsize = 10
SET @Rows = 1
WHILE (@Rows > 0 )
BEGIN
UPDATE [REMOTE_SERVER].[DB].dbo.[REMOTE_TABLE] SET VALUE = 2
WHERE ID IN (SELECT TOP (@Batchsize) ID FROM LOCAL_TABLE)
DELETE TOP (@Batchsize) FROM LOCAL_TABLE
SET @Rows = @@ROWCOUNT
END
COMMIT
But it seems to make no difference.
Any ideas/suggestions?
Thank you
View 2 Replies
View Related
Jul 8, 1999
After upgrading to SQL 7 (SP1), we have several SP's that have gone from taking 2-3 min to take 15-20. Each of these SP's creates at least one temp table, inserts into that table, then updates the records in that table. From our research, we can tell that the creation and inserts into the temp tables are fine. It is the updating of these tables that causes the problem. We can observe that the problem is happening by watching the processors go to and stay above 90%. If it were just a few SP's, we could easily fix it and go on, but because of 6.5's limit of 16 tables referenced in a SP, we had to use this method many times. Is there a fix out there for this or a configuration change I can make?
View 2 Replies
View Related
May 3, 2007
We have updated to SQL Server 2005, let€™s say, in a hurry without thinking or testing. Databases were attached to the new instance of SQL Server 2005. It looked great when I tested it alone but then a new day come and as all users logged into the system we had got a big problem. The response times are very long and users receive time out errors all the time.
A little background:
The instance of SQL Server 2005 is installed on the same server as 2000 was installed on. 2000 has been uninstalled. It is a Xenon 3.2 GHz with 2GB RAM and SCSI raid. Data and logs are on different spins.
Application is an old ASP code and some parts are not optimized at all. But it worked fine on SQL Server 2000.
What could be the problem?
I really don€™t want to downgrade to SQL Server 2000.
View 2 Replies
View Related
Mar 24, 2008
I have a user who is complaining of delays when she queries a database over a remote desktop connection. As I have no experience with this, I was wandering if there were any experts out there on how to improve remote performance in SQL Server 05. Any suggestions are appreciated.
View 3 Replies
View Related
Jan 7, 2007
Given the following scenario, what kind of performance should be expected in transferring about half a million rows? We are seeing about a 9 minute execution time. Is this reasonable for about 460,000 records moving from source to target, with 3 inner joins from the source?
Source: Server A.OLTPDB
Target: ServerA.DataMartDB
Server A is running SQL Server 2000. SSIS is running on a different machine, Server B.
The reason for this is that we are distributing the SSIS package for use with a BI product built on SSAS 2005 and the requirements are such that the client could very well have the source OLTP database on a different physical machine than the data mart.
My understanding is therefore that:
1. SSIS will do all of the heavy lifting on Server B.
2. Even though OLTPDB and DataMartDB are on the same server, it is expensive for Server B to pull the records from Server A and then send them back to Server B, but with SSIS being on a different machine, this is inevitable.
3. In the OLE DB Source Adapter, specifying table or view has the effect of an OPEN QUERY command, whereas a SQL command with straight SQL will be executed on Server B and the former would be somewhat more performant.
Can you guys validate/dispel these assumptions?
TIA,
Rick
View 12 Replies
View Related
Apr 11, 2007
Hello, I have a sql server installed on a server in my server room.
The problem I have is that when I try to connect to the server, it takes a loooooooooong time to open the connection. Even when connecting through the Sql Server Management Studio it takes about 30 seconds just to open the connection.
Can anybody help me with some pointers on how to troubleshoot this issue? It only happens with this specific server
It might be a configuration issue, but where can I find information on how to configure it correctly?
View 2 Replies
View Related
May 11, 2007
Can someone provide a step by step tutorial for this? I'd like to safely update a database that is used for a website without much or any downtime.
View 1 Replies
View Related
Jan 30, 2007
I have my first small SQl Server 2005 database developed on my localserver and I have also its equivalent as an online database.I wish to update the local database (using and asp.net interface) andthen to upload the data (at least the amended data, but given thesmall size all data should be no trouble) to the online database.I think replication is the straight answer but I have no experience ofthis and I am wondering what else I might use which might be lesscomplicated. One solution is DTS (using SQL 2000 terms) but i am notsure if I can set this up (1) to overwrite existing tables and (2) notto seemingly remove identity attributes from fields set as identities.I know there are other possibilities but I would be glad of advice asto the likely best method for a small database updated perhaps onceweekly or at less frequent intervals,Best wishes, John Morgan
View 3 Replies
View Related
Aug 1, 2007
Hi,
How do I insert data that I have collected in a local database onto a table on my online ie hosted database which is on a different server?
At the moment I am just uploading all the data to the hosted DB but this is wasting bandwith as only a small percentage of data is actually selected and used.
I thought that if i used a local DB and then update the table on my hosted DB this would be much more efficient, but I am not sure how to write the SQL code to do this!
Do I do some kind of
INSERT INTO sample_table
SELECT xxx
FROM origanal_table
Or is it more complicated than this?
Thanks
View 6 Replies
View Related
Feb 15, 2008
help sql server database triggers sample code ???
???
???
View 2 Replies
View Related
Aug 23, 2001
I used the sp_msforeachtable stored proc to disable all triggers in a database. Once the command is complete, I want to see the statuses of all
these triggers . I am used to an Oracle database so I miss the data dictionary views that easily show this info. Also, I need to view the statuses of all FKs once they are all disabled as well.
View 4 Replies
View Related
Mar 21, 2001
Hello, I have created a couple of triggers in many different tables. is there a way to run a comman in sql window to see a list of all the triggers that I created, or telling me which tables that triggers are located.
Thanks
Ali
View 4 Replies
View Related
Feb 16, 2004
Dear All,
I am trying to create a trigger on table A existing in Database A on Server A which on insert,update,delete would reflect these changes on table B in DatabaseB on Server B. I wrote the following syntax but it doesnt work
CREATE trigger trg_upd_tableA
On dbo.tableA
for UPDATE
as
--update the fields
declare @cust_no varchar
SELECT @cust_no = cust_no FROM inserted
update ServerB.DatabaseB.dbo.tableB
set
entity_type_cd = 'MFG',
cust_no = 6699,
name_en = 'NOVARTIS',
status ='A',
create_date=getdate()
,modify_date=getdate()
where cust_no= @cust_no
I get the error below
Another user has modified the contents of this table or view ; the database row you are modifying no longer exists in the database
Database Error: '[Microsoft][ODBC SQL Server Driver][SQL Server] MSDTC on server 'DatabaseB' is unavailable'
I would like anyone to reply to me as soon as possible please because i need the solution urgently
Thanks alot in advance,
Noha
View 2 Replies
View Related
Dec 19, 2007
I have an interesting problem. I am unable to see any database triggers in the Database Triggers folder under programmability in SQL 2005. I have been able to create and alter triggers in the database that function exactly as their supposed to, yet they never show up as visible in the Triggers folder. I would love for one of the luminaries on this forum to share some wisdom with me and let me know what setting is the culprit. It is driving me batty.
Thank you all in advance.
View 4 Replies
View Related
Jul 1, 2004
I got thrown into a new project that is going to require me to update an SQL server database tables from an Access table on the backend of an Oracle database on another server. At the end of each day the Access dabase will be updated from the Oracle database.
What I need to do, is when the Access database is updated I need to have the table in the SQL database automaticaly updated. When a new record is added to the Access table I need the new record added to the SQL table. When a record is deleted in the Access table I need to keep that record in the SQL table and set a field to a value (such as 0). And when a record is updated in Access, have it updated in SQL.
Needless to say this is a bit out of my area and not sure how to accomplish this.
Any help is greatly appreciated.
View 2 Replies
View Related
Jul 27, 2006
i have sql 2005 installed on my personal machine, but our server has sql 2000 on it. the structure of my database was made on the server, but i'm not sure how to update the server copy from my local copy. when i try to export my data from my local machine to the server (or import from my local machine to the server), i get pre-execute errors.
roughly every other week, i'll need to be able to update the server version from my local version, so i'm trying to find the most efficient method. what is the best way to update a 2000 database from a 2005 database? it doesn't matter if i append or overwrite, but i do use identity fields. the error i get when trying to use the import/export wizard is:
- Pre-execute (Error)
Messages
Error 0xc0202009: Data Flow Task: An OLE DB error has occurred. Error code: 0x80040E21.
An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80040E21 Description: "Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.".
(SQL Server Import and Export Wizard)
Error 0xc0202025: Data Flow Task: Cannot create an OLE DB accessor. Verify that the column metadata is valid.
(SQL Server Import and Export Wizard)
Error 0xc004701a: Data Flow Task: component "Destination 3 - ReleaseNotes" (202) failed the pre-execute phase and returned error code 0xC0202025.
(SQL Server Import and Export Wizard)
View 4 Replies
View Related
Mar 31, 2015
I set up the collector, and specify the Run As as my AD account in the Collector Set - Properties - General screen. My AD account is the local admin of the remote server.
However, the collector does not seem to work. Although the collecting set is shown as running, the The blg file stays at 64K. If I open it, there is nothing inside (no counter at the bottom). What did I miss?
View 1 Replies
View Related
Nov 14, 2000
Hello,
I am trying to create a trigger to update a table on a different database server. (Both databases are SQL server 7.0) Does anyone know the syntax of how to implement this?
Any help is appreciated!!
Thanks,
Lisa
View 1 Replies
View Related
Apr 20, 2015
I am trying to replace object name in views , triggers, stored procs, UDF,TVF etc.I have created a automated script to replace 'dbo.Cust' with 'dbo.Customer' in all objects and generate script as ALTER Statements. some objects are still scripted out as Create. Reason is it has some extra space in between
CREATE TABLE #test1(
[NAME] [nvarchar](128) NOT NULL,
[DEFINITION] [nvarchar](max) NULL,
[DEFINITION_bk] [nvarchar](max) NULL,
[type] [char](2) NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
[code]....
View 5 Replies
View Related
Feb 13, 2007
I have a database that has a table with tons of data in it and it is getting close to the 999 days before it starts deleting the oldest records. Is there a way to allow the table to keep all of the information? I don't think there is, so here is my next question. Is there a way that I can move the entire table into another database to save all the information and start over with the 999 days? My main goal here is to not lose ANY information from any table from the database.
Also, I was thinking that when an entry is added into the main table, if it can also be added into the other table where I move the old data? I think a trigger can be used here, but I'm not sure how to do one in 2005. Thank you very much in advance for your help!!!
View 1 Replies
View Related
Dec 4, 2007
Hi,
I'm aware that when bulk loading to a SQL 2005 database through an OLE DB Destination, you can enable the FIRE TRIGGERS option. Is this option available when your database target is SQL 2000? I can't find it in the Properties or other windows.
View 6 Replies
View Related
May 12, 2008
This isn€™t an problem as such, it€™s more of a debate.
If a table needs a number of update triggers which do differing tasks, should these triggers be separated out or encapsulated into one all encompassing trigger. Speaking in terms of performance, it doesn€™t make much of an improvement doing either depending upon the tasks performed. I was wondering in terms of maintenance and best practice etc. My view is that if the triggers do totally differing tasks they should be a trigger each on their own.
www.handleysonline.com
View 12 Replies
View Related
Apr 10, 2008
I am trying to use the Import Wizard to setup a daily job to import new records based on an ID field (PK). The source database is remote and a replica. I am inserting new records to update my table called the same thing. Both are SQL Native Client
Code Snippet
select *
from [CommWireless].[dbo].[iQclerk_SaleInvoicesAndProducts] as S1
join [IQ_REPLICA].[dbo].[iQclerk_SaleInvoicesAndProducts] as S2
on S1.SaleInvoiceID = S2.SaleInvoiceID
where S1.SaleInvoiceID > S2.SaleInvoiceID
When I parse the query, I keep getting an error message.
Deferred prepare could not be completed.
Statement(s) could not be prepared.
Invalid object name 'IQ_REPLICA.dbo.iQ_SaleInvoicesAndProducts'. (Microsoft SQL Native Client)
Anyone know an easy why to get this to work? Or should I add a create table to verify new records?
View 8 Replies
View Related
Oct 17, 2007
Hello,
Is there any ability to do database-level triggers in SQL 2000? I have a SQL 2000 database, and I was asked if we could create a trigger that whenever anyone touches the data in a database, to create an entry in an event log? If not, I have a main table I can put a trigger on; however, my question is how do you write to a file in a trigger as well?
Thanks.
View 2 Replies
View Related