Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 General Triggers for Tables

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-05-18 : 08:24:05
shown writes "respected sql team,

Will u be able to give me a script or coding for writing the same trigger for many tables, so that once I run the script or code,it should generate the triggers for all the tables with appropriate columns subtituted.

regards
shown_sunny"

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2004-05-18 : 08:28:57
Why would you want to do this?

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2004-05-18 : 08:46:53
http://www.nigelrivett.net/AuditTrailTrigger.html
http://www.nigelrivett.net/Triggers_2_Creating_Audit_Trails.html


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2004-05-19 : 14:08:44
quote:
Originally posted by derrickleggett

Why would you want to do this?

Dunno why shown_sunny wants to do it, but FWIW we have an SProc that generates the appropriate source code for triggers, it takes care of:

Columns for EditNumber and UpdateDate, which exist in all our tables, which get incremented/set to GetDate() respectively.

We also generally force empty [varchar] columns to NULL.

And set a CreateDate column if it happens to be NULL (rubbish imported data etc.)

And put anything from DELETED into an ARCHIVE table if one exists (original table name with "_ARCHIVE" suffixed to it, say)

Regards,

Kristen
Go to Top of Page
   

- Advertisement -