Find out filed update procedure - sql-server-2008

currently I am working inside a company with a really messy information system. I mean: the system administrator does not have a full understanding of all the procedures and processes that daily run on the net they are working on!
We have this kind of problem: every day at 5 am, a filed in a table on one database (SQl Server 2008) is updated without any sense.
My question is: if we exclude the SQL profiler, there are other way to discover major details on the procedure, process, user or application that update the field?

You can try these tools.
Profiler for Microsoft SQL Server 2005/2008
http://www.codeproject.com/KB/database/TSQL-profiler.aspx

Related

SQL Server 2012 - Data Migration to a database with modified schema

We have a database in production running on SQL Server 2012, the database was copied and then changes were made to the schema, structure, relationships during further development of our application that uses the database.
We are now ready to migrate the data from the old production database to our newly developed database. We spent a late night last night trying to figure out how to get that done using Red Gate's SQL Schema Comare, and SQL Data Compare. We were not very successful as kept getting errors during the SQL Schema Compare Deployment.
The options and features of Red Gate's tools are very extensive and I don't have much experience using them. I tried creating migration scripts within SQL Compare, but as the databases weren't linked up to source control prior, I don't see where or how to write these scripts.
The question I have is what is the proper sequence to migrate data using Red Gate's tools, or would it just be easier to create SSIS packages to handle it all. The amount of records we are migrating is relatively low less than 10,000 records. We would like to preserve the identity values as we have some scripts that may depend on the specific identity values.
Any tips, suggestions, and comments are much appreciated.
Thanks

SELECT * FROM tblXXX Returns Only One Result

I have a SQL 2008 R2 Express database that Im running an ASP.NET MVC 2 application on.
It always seems to be first thing in the morning when this problem arises - application login will fail. So I run a query against the database like SELECT * FROM tblUser and it returns only 1 result (always some random user and none of the others), making me think the records have been truncated.
So I try to recreate the admin user for example, which fails, and suddenly all users are back in the database (as reflected by a SELECT * FROM tblUser query)
Restarting the database service resolves the issue, but I need to find out why its happening. Does anyone have an idea?
SOLVED
I have a bad habit of simply copying my user instance databases and using them again in other projects that require a similar schema.
Knowing that, a friend of mine suggested scripting my entire database (including data, using SQL Management Studio) and recreating it from that.
Another friend suggested attaching the database to SQL Server 2008 full version, not Express, so I thought I'd combine the two ideas and script the database and data onto the SQL Server 2008 - which has worked :)
N.B. It also reminded me of how blisteringly fast SQL Server full version is!

One table in my SQL Server 2008 Express r2 database is timing out

I have been using a SQL Server 2008 Express R2 database for a few months now. Recently, one of my tables started timing out if I try to make an UPDATE through code or through Management Studio. I have tried making changes via the designer in management studio as well, and the same thing.
What can cause a single table to time out like this? My other tables are instant response to my changes, but this one just refuses to let me make any changes.
It sounds like your bad table has some kind of trigger attached to it. I suggest firing up SQL Profiler to see exactly what queries are being sent to the table.

Use Database Insert Trigger to Publish Reports

Is it possible to distribute reports based on a database insert trigger, using the standard edition of SQL Server 2008 R2? The trigger will be looking for a certain column to have a certain value, which will indicate that it is time to fire off a report. This will not happen very often, probably a couple of times a day.
This must be a common scenario, and yet I can't find any information on it, which must mean that I'm asking the wrong question. (I am completely new to SQL Server.)
TSQL using FireEvent?
Thanks,
Mike
Is there any aversion to checking for the value in the application, then execute and deliver the report from there using the report execution webservice? I don't like the idea of database triggers kicking off external processes. Too many clunky configuration dependencies and opportunities for failure for my taste.
If you really want to pursue this, this seems to be least complicated way (it requires reporting services and application database to on same instance):
Create reporting services subscription that delivers report in desired format
Open the SQL Server agent job list and get the unique identifier of the job name that corresponds to the subscription that was created (you'll have to look at job creation and last/next run datetime to find which job relates to your subscription)
Create trigger that executes the msdb.dbo.sp_start_job procedure, passing the job name that matches your subscription
See what I mean about clunky dependencies? I would definitely stick with checking values and delivering the report in the application layer if at all possible.
The reason you do not want to use a trigger for this is that you will not be able to insert/update/delete if reporting is down.
Can you have some slack time (5 minutes or so)? If so do a trigger to send to a differnt table that the change was made and have a job to look at that table for the change every five minutes.

VS2010 ultimate DataBase Project + SQL Server 2008: Updating Project from Database

this is a quick question:
I have this Database Project in a Web app solution with the real database. I want to update the database using SQL server managment studio, and then update the corresponding VS project.
This can be done?
I know that you can update the scripts in the project, but I'm not the SQL kind of guy, i rather do this changes using Mangment studio...
Thanks in advance
Update: Okay, the point is that I want to make changes (if I have to) on the database, using Sql Server Managment studio, and then update the scripts in the Visual Studio DataBase Project, instead of make my updates on those scripts, because I don't feel confortable writing SQL commands. Now what I do is to recreate everytime the Database Project (delete and then create again), this is what I want to avoid
Also, I have Visual Studio 2010 Professional.
It is very achievable in VS2010 Premium and I am currently doing what you describe with a Database Project and a Schema Comparison item.
Sigd is not correct in saying you can only compare Database/Project Compare, you can also compare Project / Database and Database / Database
You can achieve this using the Schema Compare feature, but this is only available with the Premium or Ultimate editions of Visual Studio, not the Professional edition.
In many cases this is possible using Red Gate SQL Compare Pro, although I should warn you that this is not a fully supported scenario just yet (I'm the product manager for this tool so I'd welcome your feedback if you go this route!).
Red Gate's SQL Source Control better fulfills your suggested way of working, although this won't help you just yet as we don't tie into VS Database Projects. Again, this is something we are considering for an upcoming release. You're welcome to try it and let us know what you think.
http://www.red-gate.com/products/SQL_Source_Control/index.htm
If only the Schema Compare tool did what it's name suggests.
Unfortunately it is a "Database/Project Compare". So my project which includes only a single schema, when compared with the database, generates loads of Create actions for all the other schema objects present in the database.
Nice idea, needs work.