Update on table really slow in ACCESS, fast in Management Studio - sql

There is a table with trigger in our SQL database. (sql server 2014). When updating record from Microsoft SQL Server Management Studio update takes like 1/10 sec. When the record is changed in MS ACCESS (in the form) it takes like 5-6 seconds to update. There is a trigger on that table, but the same operation directly from MSS Management Studio is fast, so it is not a problem with a trigger itself. THe trigger has to insert 1 record to 15 milion records table. I am looking for reasons why the same operation from ACCESS and SQL management studio can take 40 times longer. Any suggestions? Or links to known issues in that topic?
EDIT:
It's ACCESS 2003. It's subform bound to form by ID field. I am edditing simple integer column of record. I use normal connection with my sql server, it's adp project and we just use typical connection for it. I tried to do update from VBA (the same project) but from simple module -> the same effect. So it does not metter if it is eddited from form or update command is send from other module to that table. It still takes long.

To narrow things down I would still suggest to disable the trigger and see if the issue persists.

Related

Schedule a SQL Server Migration Assistant every morning to happen automattically

I have a a2ssproj that is run every morning that migrates MS Access data Tables into Microsoft SQL server Management Studio. It usually take an hour and half.
I was wondering if there is a way to use a task scheduler to execute this every morning say at 5 am instead of having to manually double click Microsoft SQL Server Migration Assistant, choosing the recent project and clicking Ok to overwrite all.
I was thinking of doing this in C# or vb.net and just importing all the data and inserting it into sql.
Is there an easy way to do this?

Editing SQL in Triggers with code

I have been migrating a database from SQL Server 2008 to 2012 and there have been problems with triggers that contain RAISERROR, because the syntax has changed between version. Now I could go through and change all of these manually, but that is a whole days work in itself.
Ideally there is a way where I can get a program to go into the triggers and change the RAISERRORs to the new syntax, this will be useful because I will upgrading another server soon and would speed up that process as well.
I have looked into SSMS Add-ins and believe they can directly edit the code within a trigger but the documentation is sparse.
I don't believe it can be done through SQL itself they can only ALTER TRIGGER, whereas I want to actually change the code inside the trigger.

Peculiar happenings in SQL Server

I have just started an internship in I've had to learn a lot on my own. I'm learning MS SQL Server, but having a strange problem. I have a DB that has four small tables. Each one has a script to drop the table, recreate the table (I've avoided FK dependencies for the time being), and execute a demo query.
Problem 1: When I first started SQL Server Managmenent Studio would execute the script, but one table didn't show up in the Object Explorer. If I tried to execute a demo query from the same .sql file, it executed with no problem. If I tried to access it from another .sql, the table didn't exist. After many times of successfully executing the script, it finally just showed up.
Problem 2: Similar problem. When I updated one table, the changes wouldn't be reflected in queries.
Problem 3: Queries will fail, but if I click execute again with no changes being made, it will usually work correctly.
Problem 4: When I use an alias for a field name, sometimes the alias is recognized and sometimes it isn't. I've literally had single query in which the alias would work in one place, but not work in another and I had to use a fully qualified name.
I've tried the refresh and refresh local cache, but those seem to have no effect. If I exit Management Studio, that seems to usually fix the first two problems.
Am I going nuts or am I just in the dark about some weird specifics of SQL Server?
First of all, when you make a schema change you need to right-click on the "Tables" node for the database in management studio and hit refresh.
If you change a column or something in a table, right-click the table and refresh.
The refresh local cache only updates the intellisense stuff, and the refresh only updates the GUI. If you modify a table with SQL and do not refresh it in the UI, the query can still use the updated table.
If you query fails, you either have a bad query or it's not pointed at the database or connection you think it is.
For aliases, there are places where they will not work (update statements, for example) but if you don't post queries where they don't work we cannot read your mind and tell you what's wrong.
If you have specific queries that are failing, post them.

Get Data from a Website and update a SQL Server 2008 R2 Table

I'm wondering if it is at all possible to take data from a website and update a table in SQL Server 2008 R2 at a given interval of time?
The website in question updates every 5 minutes, changing the values of two numbers. As stated above I'm using SQL Server 2008 R2 and I also have Visual Studio 2013 if that matters at all. I need to take these two numbers every 5 minutes and update a table I have created on the SQL Server.
I know I can use an Excel macro to do this, which I already have done, but my employer wants to bypass this altogether.
If this is possible, say via a VS application, then any helpful links or suggestions would be greatly appreciated.
Thanks in advance!
You can create an SSIS package with a "script task".
This task could read the website and return the information.
Then store it in your table.
To finish configure a job that call this SSIS package every 5 minutes.

How to use Triggers in SQL Server 2012 to archive and delete

I will be honest, I know nothing about SQL Server other than what I have tried to pack into my brain in the last two days.... I have found a couple of scripts on your website that sounded like they would work What are ways to move data older than 'Y' days to an archive/history table in MySQL?. This one in particular really seems like it would fit my needs.
But I want to insert the data into a table or database on another partition of the same server and can't figure out how to change the location.
I have SQL Server 2012 Express, running on a Windows Server 2008 R2 service pack 1. We started the database on 11/21/2013 and we hit the 10 GB limit on 12/30/13. We design crowns & bridges, implants and dentures so we have multiple CT scans per patient that get manipulated in 3D imaging and CAD programs multiple times so it creates a lot of data very quickly.
Questions:
Should I try to use the triggers built in to my PatientNetDB? [OnAfterDeleteDataSets & OnAfterInsertDatasets]
If so how do I change it to make it work like the question from the user I copied above?
We may need to pull data back out of this archive, how in the heck do I do that?
I really appreciate any help you can give me, remember I am a total newb to this stuff and unfortunately will need extremely simple step by step or copy and paste directions/scripts.
Thank you so much!
Linda Saylor
No, don't use triggers for archiving/deleting. Trigger are fired when specific operations occur - INSERT, UPDATE or DELETE - on certain tables, and you cannot control when and how often triggers are fired. Therefore, triggers should be very small and nimble - you should NOT put large and long-running operations into a trigger. A typical trigger might update a row that's been inserted, or it might put a row into a separate table (an Audit or Command table) - but the trigger itself should never much processing.
What you can and should do is to have scheduled tasks - unfortunately, the SQL Server Agent is not available in the Express edition. With SQL Server Agent you could run certain processing operations (T-SQL scripts) at scheduled intervals, e.g. once every night etc.
Since you're using the Express edition, you'll have to find another way to run a task at given times, possibly by writing a small wrapper in your language of choice (C#, VB.NET, whatever), have that scheduled by the Windows scheduler (Scheduled Tasks in your Windows start menu), which would then kick off / execute a T-SQL script to run the cleanup process and archive your data.