Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Instead of Update trigger for from-thru dating
Message
 
À
25/01/2012 18:15:44
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2008
Application:
Desktop
Divers
Thread ID:
01533754
Message ID:
01533757
Vues:
34
I have similar triggers for some of my tables, I use null instead of a future date, but similar idea. I use something like this:
ALTER TRIGGER NameOfTrigger
   ON YourStatusTable
   AFTER INSERT
AS 
BEGIN
	UPDATE YourStatusTable SET thru_date = getdate()
		FROM inserted where inserted.YourForeignKey = YourTable.YourForeignKey and thru_date  = '20500101'
END
Not sure if I am clear in my explanation, I assume that the trigger is on a Status table and YourForeignKey is the reference to the real table
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform