473,387 Members | 1,517 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

BACKUP TABLE(historical)

How to build a TRIGGER that copies, all the time, the data from the table on
which the transaction occurs to the historical table?
thanks

Fernand
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.659 / Virus Database: 423 - Release Date: 2004-04-15


Jul 20 '05 #1
1 2193
/* INSCRIRE LA DATE DU JOUR LORS DE LA MODIFICATION D'UN TEXTE */

CREATE TRIGGER maj_texte ON dbo.TEXTES

FOR INSERT, UPDATE, DELETE

as

DECLARE @ident_text INT

SELECT @ident_text = ID_TEXTE

FROM deleted TEXTES

UPDATE TEXTES

SET DATE_JOUR_USAGER = CURRENT_TIMESTAMP

FROM [TEXTES]

where ID_TEXTE = @ident_text

/* INSCRIRE LES DONNÉES HISTORIQUES DANS LA TABLE DE CONTRÔLE DE TEXTE */

INSERT INTO [CONTROLE_TEXTE]

(ID_TEXTE, STATUT, DATE_CREATION, DATE_MODIFICATION,DATE_MISE_A_JOUR,
DATE_TOMBER, DATE_EXPIRATION, DATE_JOUR_USAGER, TITRE, SOUS_TITRE,
INTRODUCTION, TEXTE, AUTEUR, VERROUILLER, TEMPLATE, ID_LANGUE, ID_IMAGE,
ID_SECTION_SITE)

SELECT ID_TEXTE, STATUT, DATE_CREATION, DATE_MODIFICATION, DATE_MISE_A_JOUR,
DATE_TOMBER, DATE_EXPIRATION, DATE_JOUR_USAGER, TITRE, SOUS_TITRE,
INTRODUCTION, TEXTE, AUTEUR, VERROUILLER, TEMPLATE, ID_LANGUE, ID_IMAGE,
ID_SECTION_SITE

FROM inserted TEXTES

"Fernand St-Georges" <fe****************@videotron.ca> a écrit dans le
message de news: Sw******************@weber.videotron.net...
How to build a TRIGGER that copies, all the time, the data from the table on which the transaction occurs to the historical table?
thanks

Fernand
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.659 / Virus Database: 423 - Release Date: 2004-04-15

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.659 / Virus Database: 423 - Release Date: 2004-04-15
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Fernand St-Georges | last post by:
How to build a TRIGGER that copies, all the time, the data from the table on which the transaction occurs to the historical table? thanks Fernand --- Outgoing mail is certified Virus Free....
0
by: Leif Neland | last post by:
I'm logging mail to a database, and using php to make queries. The mail is coming in constantly, so the table is being added to, in batches of up to 30 mails. I have around 600k records. The...
3
by: tho_pic | last post by:
Hi gurus, May be my question is funny to all of you guys but I don't know why we have to keep the backup and recovery history of databases in msdb. I try to read BOL & other documents but no...
1
by: rottytooth | last post by:
A general data design question: We have data which changes every week. We had considered seperating historical records and current records into two different tables with the same columns, but...
3
by: dunleav1 | last post by:
I am trying to write a sql script to estimate size and count of rows of all tables and indexes within a schema. Here's what I have so far but need a little help. #$1 is database name and $2 is...
3
by: Erwin | last post by:
I have a work assignment in which I have to put a historical archive within access which can be used for trendlines etc. It contains data about month, service percentages and numbers. Within a...
0
by: Marc DVer | last post by:
I have the following example table (t1): userIDEditIter int(10) unsigned primarykey autoincrement userID int(10) unsigned userName varchar userType varchar userLastEditDateTime DateTime I...
2
by: igendreau | last post by:
I need to have a form where my users can enter job info. One thing they need to enter is "Regular Hours". What I need to do is then calculate "Regular Cost" which =Regular Hours x Regular Rate...
1
by: sbowman | last post by:
I'm in the process of creating a monthly reporting database. I've worked out all the queries which are all counts of particular field values. I need to store these values in a table for historical...
7
by: billelev | last post by:
Hi, I need to insert asset pricing data from one table that is updated multiple times daily, to another table containing historical data. The fields in both tables are: Symbol, Date, Price. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.