Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
To create History table to record changes in fields
Message
De
15/07/2006 02:40:24
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Versions des environnements
SQL Server:
SQL Server 2000
Divers
Thread ID:
01135878
Message ID:
01136630
Vues:
11
Hi, Bharat,

First, again, I recommend against using the UPDATE function, which will only tell you if a column is specified in an UPDATE statement. If I repeatedly issue the command...
UPDATE MyTable SET FirstName = 'Kevin'
...the UPDATE function will return a true for the firstname column, every time. You need to join the Inserted and Deleted columns to see if something truly "changed".

Also, I'm not sure if your code is going to work if a single UPDATE affects multiple rows. In SQL Server, an update trigger fires one per UPDATE statement. So make sure your code will handle an UPDATE that affect multiple rows.

The code you posted may "work", but will be compartively more difficult to manage. Imagine how complicated your logic will become once you start to add more and more columns to the mix.

You're probably better off reearching update triggers and doing some more reading, to get a stronger handle on how to manage something like this. If you're saying you're not that good at writing scripts, fine - but I would suggest you invest some time and make yourself better at it.

Kevin
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform