How Can I Detect Changes Automatically In The SQL Server Database When Anything Is Updated..?
Mar 13, 2007
I been asked recently in the interview that
How can I detect changes automatically in the SQL Server Database when anything is updated, deleted or inserted?
if anyone can help me in this that will be really great.
I dont actually know whether I can ask this here but I wanted to know the answer for this and thought this might be right place to ask?
Hello, I am using SQL Server 2005 and ASP.NET 2.0. We have a very simple content management system where we have to keep track of date last modified for each row in all of our content tables. I know there's a "timestamp" datatype that is used for replication scenarios, but is there anything similar that I can use to set up a date_modified column for each of my content tables that will automatically update with GETDATE() whenever anything in a given row is updated? Or do I have to create a date_modified column of smalldatetime datatype and write a trigger on update for EVERY single table of content that I have in the database? It seems there should be an easier way to do this than to write 20 triggers for my 20 content tables. Thanks!
I know 2008 MS SQL Server has a timestamp data type that adds date and time when the rows are inserted. Is there a way to automatically update the date and time when the rows are updated?
is there a way to find out that SQL Server 2005 (Express) engine is performing startup checked of a selected database?
The problem we are faced to is that our users shutdown brutally their laptops running their database. When they start laptops again, they impatiently start the application that tries to connect to the database. However, they get an error message:
Cannot open database XXXXX requested by the login. The login failed.
When they try after a minute or two, it works.
What we would like to do is provide an information message that the SQL server is checking the database and that they must wait for a while. Is there is a specific error code for this, can anyone help? We are using .NET 2.0.
Hello everyone,I have a webcontrol that uses database-structures alot, it uses the system tables in SQL to read column information from tables. To ease the load of the SQL server I have a property that stores this information in a cache and everything works fine.I am doing some research to find if there are anyway to get information from the SQL server that the structure from a table has changed.I want to know if a column or table has changed any values, like datatype, name, properties, etc.Any suggestions out there ?!
We installed SP1 for SQL Server 2014 this past weekend and got this error message in the logs. I found that if you set the db to read-write, it updates the system objects, even after SP1 has completed. Then you can set it back to read-only. I'm just posting this so other people can find it on the internet, as I wasn't able to find it specifically.
Error Log Entry:System objects could not be updated in database 'x' because it is read-only.
Problem: After installing SP1 for SQL Server 2014 you will find this message in the error logs saying read-only databases could not be updated.
Solution: Simply set the db to read-write and the system objects will get updated, long after SP1 was installed.
ALTER DATABASE [x] SET READ_WRITE WITH NO_WAIT
Then set it back to read-only:
ALTER DATABASE [x] SET READ_ONLY WITH NO_WAIT
You should then see these log entries:
System objects could not be updated in database 'x' because it is read-only. Setting database option READ_WRITE to ON for database 'x'. Starting up database 'x'. CHECKDB for database 'x' finished without errors on 2015-07-25 01:02:28.143 (local time). This is an informational message only; no user action is required. Synchronize Database 'x' (129) with Resource Database. Setting database option READ_ONLY to ON for database 'x'. Starting up database 'x'. CHECKDB for database 'x' finished without errors on 2015-07-25 01:02:29.888 (local time). This is an informational message only; no user action is required.
our clients have the flexibility to detach and attach databases (I know there are a lot of considerations around this but there is now way of changing it), once they attach a database we need to run some code to update a bunch of values in the database.
Other than creating a SQL Agent job are there any other options available to automatically execute a script once the database has been attached?
I come cross some post about how to backup a database in Sql Server Management Studio Express automatically. The scripts look like as below
USE [master] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE PROCEDURE [dbo].[sp_BackupDatabase] @databaseName sysname AS BEGIN SET NOCOUNT ON; DECLARE @sqlCommand NVARCHAR(1000) DECLARE @dateTime NVARCHAR(20) SELECT @dateTime = REPLACE(CONVERT(VARCHAR, GETDATE(),111),'/','') + REPLACE(CONVERT(VARCHAR, GETDATE(),108),':','') SET @sqlCommand = 'BACKUP DATABASE ' + @databaseName + ' TO DISK = ''C:Backup' + @databaseName + '_Full_' + @dateTime + '.BAK'''
EXECUTE sp_executesql @sqlCommand END
It throws that the DDL statement is not allowed. What's wrong with it?
We have a production server "prod" which has a user say 'test' that lets the users connect to the application and a logon trigger which stops them from connecting to the server through SSMS. I log ship 'prod' to the 'rep' database and the user 'test' is obviously created in the logshipped database 'rep' during the logshipping.
Now the login 'test' does not have any login from server 'rep', But people can still login to the 'rep' server and query the 'rep' db . I checked with SUSER_SNAME and found the SID of the user in rep server which I never created and which is not even present in the login names, Even If I create a new username in the 'prod' db, after logshipping the new user is replicated in the 'rep' server.
I am currently writing an install wizard for my web application. One of my steps is Installing asp.net membership, roles, and session state to the new database. My wizard detects if this step has already been completed through the page_Load event. Currently I am writing makeshift code just to see if the tables exist.Does ASP.Net provide a way to detect what services have been installed on the database? So far I have only found Install and uninstall functionality in the System.Web.Management Namespace.I have been searching for this for a while, I am sure this question has been answered somewhere, but there is so much base information on how to initially set up membership that I cant seem to find the answer.
I have database on localhost and i want to show this data on my website. I want to create a database online and want to sync with Local Host. Can it be possible syncing data automatically after some interval?
Hi guys, may I know is it possible to create an update trigger like this ? Assuming there are two database, database A and database B and both are having same tables called 'Payments' table. I would like to update the Payments records on database A automatically after Payments records on database B had been updated. I can't use replication because both tables might having different records and some records are the same. Hope can get any assistance here, thank you.
I am setting up SQL audit on sql servers in my environment based on requirement. I want to create database specifications ASAP database created. I tried DDL trigger but Audit doesn't support triggers. So I created audit specifications on model database. the only problem with this is every specification created on new database with same name.database specification name includes newly created database name or other methods to create database specifications on newly created databases.
in the database, there is some information about the applicant: his name, his email, his status (accepted or rejected)....etc. the page that is shown to the administrator displays the applicant name and his status, when he changes any of the applicants status, an email is sent to that applicant. is there any way to do that? thanks in advance
Till yesterday every thing was fine....after i installed visual studio...god knws wat happnd dat it was not working, i did everything again but noe using my asp.net forms i am unable to write/edit/update the database, though i can view the same.....can any one suggest was might b d problem.
(i have set permissions for IUSER bot Read and Write)
I need to be able to programmatically detect whether or not SQL Server 2005, anything from Express on up to the full package with all the bells and whistles, is installed on the computer regardless of which service pack (if any) is installed. I found a forum article that provides a Registry setting that I could look at, but in the reply to the original post, it recommends using WMI instead of Registry keys. Also, I don't know whether or not the Registry key given for SQL Server 2005 would be present for even the minimal package. (Our requirements are for at least the Express package, and I understand that there's an even more basic package than that.) I'm maintaining a couple of installers that use 5-year old InstallShield technology (and Visual Studio 6 for any C/C++ code that I have to create) that have to check whether or not SQL Server 2005 Express (or a fuller package) is installed. I have done no SQL Server programming, so I've never even heard of WMI. Also, because these are installers, they have to work out of the box with no requirements to install anything beforehand to allow the installer to work. (We are working on an MSI-based installer with a bootstrap executable (the latter built using Visual Studio 2005) that will replace the older installers in the next version of our software, but we still need to support the older installers for now. Therefore, an out of the box solution that works with the older technology that we are still using for the older software is imperative. As the older software supports Win2k, the SQL Server detection solution must do so, too.)
I am making web application using Asp.net C#(Visual Studio2005). And Sql server 2000 as a back End.
Actually I am fetching data from other database(named as retailexcel but in same server). I have wriiten a view (in retailexcel database) to get required data from four table of other database. My problem is when I fetch those data(about 40000 to 50000 record) It taking to much time. I tried catch feature of asp.net2.0. Time reduced but not significantly. So I am trying to import those tables to my database (named Inventory) from that retailexcel.
Now problem is every day or two, record of those tables changes. How can I keep update my tables (which are importing from retailexcel)
I am developing a windows forms app in Visual C# Express edition, it has a database, and when I am debugging, nothing is being done in the database, and I am sure it is nothing to do with the code. Because all I am doing is creating a database with one table, and just dragging the table (with the datagridview) onto a form, then it runs perfectly, but when I add or delete records, and exit the program, it is not reflected on my DB (which is a SQL Server express DB by the way),
I was looking everywhere, and all I could find was to change the "copy to output directory" propierty of the DB to "copy if newer" but still it doesn't work,
I am trying to create a data dictionary for a huge application which has aroung 300 tables in the database....when i perform any operation in the application some tables are updated.... can you help me to find out how can we find out the last updated tables in the database ??
I have very little, to zero, IT configuration knowledge and I am hoping that someone is able to help me out.
I am currently writing the SQL scripts and developing the reports in the SQL Server Business Intelligence Development Studio, and then deploying the reports to the server for managers to eventually view.
Recently the IT section updated the test database (temp) that is connected to SQL Server 2005, with the live database (production), so that the data and database structure were up to date for me to create the reports.
When the update was done, the connection to SQL Server failed, and the newly appointed IT person responsible for SQL does not know how to resolve the problem. Up until yesterday I was getting a message that said that the connection has failed and then today I have the following message (she has been trying very hard to get it working):
An error occurred during local report processing. An error has occurred during report processing. Query execution failed for dataset 'Division'. The SELECT permission was denied on the object 'Dim1', database 'payglobal', schema 'dbo'.
The reports that were deployed to the server prior to the update are still accessible however I am unable to review any reports I edit within the Development Studio. It has been out of action now for nearly two weeks.
Could someone please give me very detailed instructions on where the IT person should look, and what she should do to fix the problem. I will then pass these onto her.
I am working on an existing infrastructure and i do not have liberty to change much right now. I am in a situation where app issues update statistics command quite often. So frequently that sometimes one blocks another. Is there any way i can do something like this
IF ( update_statistics going on) dont do anything else run update statistics
This is temporary solution untill i fix bad inline SQL code (in app) and use SPs.
Upgrade Advisor could not detect SQL Server components on the server.
===================================
The network path was not found. (mscorlib)
------------------------------ Program Location:
at Microsoft.Win32.RegistryKey.Win32ErrorStatic(Int32 errorCode, String str) at Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(RegistryHive hKey, String machineName) at Microsoft.SqlServer.UpgradeAdvisor.SqlDetection.GetClusterInfo() at Microsoft.SqlServer.UpgradeAdvisor.SqlDetection.DetectComponents() at Microsoft.SqlServer.UpgradeAdvisor.FormDetectComponents.Detect()
I am new to connecting to databases through java and in fact have not done much database programming although I am fairly good at SQL. I have used the MS JDBC driver to connect to a MS SQL server database but I want to update my application every time a record is added to the database and or alert the user. From what I have read, i assume that I can create a Trigger in java but how do I get my trigger to call a method / run java code?
i just kicked off a job that starts a data driven subscription that generates ~200 excel spreadsheets.
I kind of expected them to appear in the execution log, and that the TimeEnd would reflect when they complete.
instead, it appears that the TimeEnd is when the SQLcommand finished executing, ie, a few milliseconds after the start.
it does not reflect when the report finishes completing; if i run sp_whoisactive, i see a stack of reports at a time clawing their way through the process. (ie i see calls to [CreateChunkStatement] and all the other steps a report kicks off.
Other than watching execution requests, how can i know if anything is running as far as subscriptions go?
I am using SMO EnumAvailableSqlServer to make a list of available SQL servers in local network. I have tested it in two different local networks. In the first all works fine, but in the second I have noticed that when disconnected from the network the call fails to even detect the locally installed sql servers. I know that I can scan registry to get installed local servers, but I want to know what could be making problem.
Hi,I want to save the last modification date when the row is updated. I have a column called "LastModification" in the table, every time the row is update I want to set the value of this column to the current date. So far all I know is that I need to use a trigger and the GetDate() function, but could any body help me with how to set the value of the column to getdate()? thanks for your help.
Does anyone know at what point SQL Server 7.0 decides to grow the database when the autogrow option is set? Our site just went down for 45 minutes because the growing process was taking too long as compared to the data coming in, so the device filled up.
Ray? Craig? You guys seem to know all, so jobs.com appreciates your input...