Reflect the changes made in one table in sql to reflect automatically on another table - sql

I have created a table in SQL by copying data from another table in a different database. How can I make the changes made in the old table get reflected in the new table automatically?

You can use a Trigger function to reflect the changes.
Refer this.
Given that you have access over the First table, Trigger would work fine.

Related

Trigger to copy data from a view to a table - T-SQL

I'm wondering if there is any way to copy data from a view to a table in the same database. To be more clear, I have a view called AUTHORS_VIEW and a table called AUTHORS_TABLE. AUTHORS_VIEW takes data from others table in others databases.
I would copy new records in AUTHORS_VIEW not yet existing in AUTHORS_TABLE, update records in AUTHORS_VIEW not yet updated in AUTHORS_TABLE and remove record flagged as Removed in AUTHORS_VIEW from AUTHORS_TABLE.
Is it possible to achieve this with a trigger or others tool? I'm newbie with SQL Server.
This is my AUTHORS_VIEW (AUTHORS_TABLE is identical):

Create a trigger for making a single audit table in sql server

How do I create a trigger in Microsoft SQL server to keep a track of all deleted data of any table existing in the database into a single audit table? I do not want to write trigger for each and every table in the database. There will only be once single audit table which keeps a track of all the deleted data of any table.
For example:
If a data is deleted from a person table, get all the data of that person table and store it in an XML format in an audit table
Please check my solution that I tried to describe at SQL Server Log Tool for Capturing Data Changes
The solution is build on creating trigger on selected tables dynamically to capture data changes (after insert, update, delete) and store those in a general table.
Then a job executes periodically and parses data captured and stored in this general table. After data is parsed it will be easier for humans to understand and see easily which table field is changed and its old and new values
I hope this proposed solution helps you for your own solution,

SQL - Record Every Statement That Updated Table

I am working on a database used by separate applications. One of these applications is updating two fields in a table but I can't work out what one and don't have the source code for all the applications.
I am wondering if it is possible to write a log (to another table or elsewhere) to what the last update statement made against the table in question was. E.g. to record all SQL that has attempted to update the table automatically...
create a trigger before update on this table. Also create a new table. In that trigger store values before and after update in to a newly created table

Method in SQL Server for making a copy of a table and refreshing it?

I'm trying to figure out if there's a method for copying the contents of a main schema into a table of another schema, and then, somehow updating that copy or "refreshing" the copy as the main schema gets updated.
For example:
schema "BBLEARN", has table users
SELECT * INTO SIS_temp_data.dbo.bb_users FROM BBLEARN.dbo.users
This selects and inserts 23k rows into the table bb_course_users in my placeholder schema SIS_temp_data.
Thing is, the users table in the BBLEARN schema gets updated on a constant basis, whether or not new users get added, or there are updates to accounts or disables or enables, etc. The main reason for copying the table into a temp table is for data integration purposes and is unrelated to the question at hand.
So, is there a method in SQL Server that will allow me to "update" my new table in the spare schema based on when the data in the main schema gets updated? Or do I just need to run a scheduled task that does a SELECT * INTO every few hours?
Thank you.
You could create a trigger which updates the spare table whenever an updated or insert is performed on the main schema
see http://msdn.microsoft.com/en-us/library/ms190227.aspx

Altering a on attribute data size from a table in SQL Server

So I'm trying to do something I thought would've been straightforward. I have a table in the DB named "Images." It's 'Description' property is of type nvarchar(50). I simply want to make it nvarchar(250). Every time I try, it says it can't save because some tables would have to be redropped. I can't just delete it (i think) because, there's already data being maintained by it, and I can't lose it.
EDIT::
Exact error message
"Saving changes is not permitted. The
changes you have made require the
following tables to be dropped and
re-created. You have either made
changes to a table that can't be
re-created or enabled the option
Prevent saving changes that require
the table to be re-created."
Should I just disable the 'Prevent saving changes that require table re-creation' and save it from there.
This KB article explain it
Do you have any tables referencing the "Description" column? That would prevent you from changing the data type/length.
Were you doing this from the SSMS GUI or were you running a script using alter table to make the change?
IF you did it through the designer, I believe it creates another table, drops the orginal and renames the new table. If that table is in a PK/FK relationship. it can't drop the table. Never make table changes except by using a script. YOu also need these to properly put them in source control as well.