I have a very strange and complicated situation. I have data being erased from one of my SQL Server tables, and I am not sure by what application. I would like to be able to track this.
As I am sure you are wondering how I could find myself in this situation, here is some background. We have 2 servers, Web and Database running IIS6 and SQL Server 2005 respectively. They were setup by the previous developer who left the company without giving me any sort of introduction to the system so I am left "hunting" for everything.. I have been able to figure out most of the system on my own except for this, which remains a mystery. All I know for sure is this:
Data is being erased at a set time every day (I have setup a TRIGGER to capture this)
It is not a SQL Server Agent Job
It is not a Windows Scheduled Task
It is not a Windows Service
All database logins are done with the sa user so login history cannot help me... (again, I didn't set this up)
How the heck do I debug something like this? If anything, I want to know if this is coming from something running on the database server, or from a request from an outside source. Please help :-)
As you know the time it happens you should set up a SQL Profiler trace at that time to catch the statements being sent.
This will show you the SQL being sent, the spid of the connection, user name, application name sent by the connection and other useful info to track down the culprit.
In case the time that it happens is not convenient for you to do this you can script SQL traces (which is more lightweight than running the full GUI anyway)
Edit: Be careful when using it not to record so much information that you bog down the server. You can filter for activity on the database of interest for example.
Related
I'm developing a .NET desktop application with SQL Server as the database backend. One of the requirements of the application is that if a record status, for example, remains inactive for 30 days, there will be a reminder email sent to the user associated to that record.
This could be done pretty easily within the application, as long as it is started and running. However, assume that for a certain period of time, nobody starts up the application, the reminder email won't be sent, because nothing / nodody triggers the action.
How about creating a job in SQL Server which can monitors the records and sends emails as needed? Has anyone ever done that?
Thanks a lot!
Given the requirements of your task, I suggest that you create a console program (w/ C# or VB.NET) that checks for inactive (30 days) row condition and then generates the appropriate email notification message. Then run this program every hour or so (depending on the urgency involved in detecting an inactive row condition) using a SQL Server Agent Job.
The following image shows how the SQL Server Agent Jobs are displayed in the Object Explorer for SQL Server 2008 R2.
This SO entry covers some aspects on creating a console program that runs at certain times. The SQL Server Job Agent has several scheduling options that should facilitate your needs.
You might be reluctant to create a console program for this, but you are apt to find that doing so gives you options that are simply not easily implemented with a pure SQL Server based approach. Plus, you may have future needs that require similar processing that this approach provides.
Background
To make the story short, our company is facing the task of making our application redudant and more resilent to heavy loads by load-balancing. The task is on my desk and I've been doing some research as I've never done it before.
Fact
Today we host our application on 1 server and the goal is to have another one to even out serverload with load-balacing.
Issue
I've been doing some research and got stuck on how to setup the MSSQL Replication. If one server goes down the other one must be in sync as the users will be redirected there insted by the load-balancer
The tenthousand view to the solution goes something like: Have a Publisher/Distributor on same server and then add subscriber databases and they will sync between eachother.
Question
What happens if the Publisher/Distrubtor server goes down? Suddenly the system isn't redudant at all. Do we have to setup a Publisher/Distrubtor on each subscriber server to take over the role? I've been search around and haven't found a good answer.
Just hint if the explanation is confusing and I'll fill in the blanks..
Thanks in advance!
We have about 200 customers and the semi-manual remote sql update for every new version has become taxing.
I want you guys to help me find a better solution. A real automatic update of the databases.
Let me describe you the scenario.
Each customer has a server that runs SQL Server Express 2005 or 2008 which is not accessible to them and client PCs with our application (written in PowerBuilder).
Every night, in a client PC that runs our application, they perform a "close day" operation so that all the daily statistics to become permanent and have the application into the new date.
Preferably I would like, when this operation finishes, to launch e.g a service in the server PC that can check the version and if needed to download SQL files and execute them via OSQL.
The hard part for me is how I can trigger a service (or whatever) from a client PC to the server when the "close day" operation finishes. OSQL can run only from the server. I have no way to install it in a thousand client PCs.
Then I can take it from there since I know how to handle OSQL calls etc.
Every help appreciated.
Thanx in advance
Can you set up a scheduled job on the server to check the contents of a control file for a certain entry and then fire off the process once it finds it? If so then have the client application write to the control file once its 'close day' is complete.
We have an application which has a SQL Server 2000 Database attached to it. After every couple of days the application hangs, and we have to restart SQL Server service and then it works fine. SQL Server logs show nothing about the problem. Can anyone tell me how to identify this issue? Is it an application problem or a SQL Server problem?
Thanks.
Is it an application problem or a SQL Server problem?
Is it possible to connect to MS SQL Server using Query Analyzer or another instance of your application?
General tips:
Use Activity Monitor to find information about concurrent processes, locks and resource utilization.
Use Sql Server Profiler to trace server and database activity, to capture and save data to a table or file to analyze it later.
You can use Dynamic Management Views (\Database name\Views\System Views folder (in the Management Studio)) to get more detailed information about MS SQL Server internals.
If you have the problems with perfomance (not your case) - you can use Perfomance Monitor and Data Collector Sets to gather perfomance information
Hard to predict the issue, I will suggest you to check your application first.Check what all operations you are performing against data base, are you taking care of connection pooling, unused open connections can create issues.
Check if you can get any log from your application. Without any log information hardly we can suggest anything.
Read this
Application may be hanging due to Deadlock
check the SP runs at that time using Profiler
and check the table manipulation(use nolock),
check the buffer size and segregate the DB into two or three module.
Consider that i have a maintenance activity on my dataserver which hosts a lot of databases. Now before the maintenance , I would like to make sure that there are no writes/updates happening to the database for atleast 2-3 hours. Is there a way to know this ? Although i can make sure that all the jobs contacting the dataserver are all held during the maintenance , Having a way to know this for sure would help.
Thanks
You can use Sql Server Activity Monitor for Checking the current Activities going on in the server.
In SQL Server Management Studio, You can also open Activity Monitor at any time by pressing CTRL+ALT + A.
In activity monitor you can see. Active User Tasks,Resource Waits, Data File I/O, etc
You can get a detailed description at http://msdn.microsoft.com/en-us/library/ms175518.aspx
You can use the SQL Server Profiler in order to see if there is any activity on the server.