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 2005 Forums
 Transact-SQL (2005)
 Trigger the best practice ?¿

Author  Topic 

Mjolnir
Starting Member

12 Posts

Posted - 2010-06-11 : 09:47:09
Hi,

I want to use a trigger to do the following:

The all complete registers are copied to other database with name DB_AUDITS is a real copy from DB_NORMAL.

the triggers is:



CREATE TRIGGER TD_ARCHIVOS ON dbo.ARCHIVOS
FOR INSERT, DELETE, UPDATE
AS
Insert Into ARCHIVOS
([ACID]
Select
[ACID]
From DELETED

Insert Into ARCHIVOS
([ACID]
Select
[ACID]
From INSERTED



End

GO


is good practice to its? I dont know who do I to pass from DB to DB_AUDITS?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-06-11 : 12:31:32
If your intention is to audit data changes, then doing it in a trigger is the best way.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

Mjolnir
Starting Member

12 Posts

Posted - 2010-06-11 : 16:35:56
thank you Tara.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-06-11 : 16:37:24
You're welcome.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -