If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Microsoft SQL Server > SQL Server 2008 functionality for Audit Log

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-18-09, 01:11
totaltech totaltech is offline
Registered User
 
Join Date: Nov 2009
Posts: 4
SQL Server 2008 functionality for Audit Log

Hello

I have to implement a functionality for audit ( insert/update/delete ) log of the each table.
There are two option
1) Through SQL Server 2008 Feature : I heard that in the SQL Server 2008 we have CDC(Change Data Capture) features which can be enable on each table and track each data changes. It insert new row into a special system table which we need audit log.
2) Create a un normalized table for each table and handle the audit (insert/update/delete) log using the trigger.

Can anybody help to me to choose which options is best and easy to manage in the future?

Thanks,
Craig
Database Development Company San Diego
Reply With Quote
  #2 (permalink)  
Old 11-18-09, 02:23
dportas dportas is offline
Registered User
 
Join Date: Dec 2007
Location: London, UK
Posts: 732
CDC. It takes only a few minutes to enable it and the impact in most cases should be minimal (of course you should make sure you test it). Triggers introduce lots of complexity and frequently harm performance and make support and development more difficult.
Reply With Quote
  #3 (permalink)  
Old 11-18-09, 02:36
totaltech totaltech is offline
Registered User
 
Join Date: Nov 2009
Posts: 4
but, how we can get data if we use CDC in the asp.net

Craig
Database Development Company San Diego
Reply With Quote
  #4 (permalink)  
Old 11-18-09, 09:41
blindman blindman is offline
World Class Flame Warrior
 
Join Date: Jun 2003
Location: Ohio
Posts: 11,726
Triggers are not only appropriate for this type of business logic, in my opinion they are the best solution and I have been implementing archive tables using them for years.

Here is a link to a script you can run which will itself generate a script for adding archive tables and supporting triggers to an existing database:
http://dl.dropbox.com/u/2507186/Scripts/AutoArchive.sql

I have not played around yet with 2008's auditing features, but my initial impression is that it would not give me the fine-tune control that I get by implementing my own scripts.
__________________
If it's not practically useful, then it's practically useless.

blindman
www.chess.com: "sqlblindman"
Reply With Quote
  #5 (permalink)  
Old 11-18-09, 17:38
dportas dportas is offline
Registered User
 
Join Date: Dec 2007
Location: London, UK
Posts: 732
Quote:
Originally Posted by totaltech View Post
but, how we can get data if we use CDC in the asp.net[/URL]
Same way you access any other data. With a query. Usually in a stored procedure. You access CDC data with a SELECT statement.

Quote:
Originally Posted by blindman View Post
Triggers are not only appropriate for this type of business logic, in my opinion they are the best solution and I have been implementing archive tables using them for years.
You would use triggers rather than CDC? Any particular reason other than familiarity? One of the disadvantages of a trigger for audit is that the audit all happens in the transaction, which means your server works twice as hard. CDC reads the log and it does so asynchronously so the overhead is almost negligible.

If you only have Standard Edition then you don't have CDC so that's a reason to use triggers (or to upgrade).
Reply With Quote
  #6 (permalink)  
Old 11-18-09, 17:49
Thrasymachus Thrasymachus is offline
SQL Server Street Fighter
 
Join Date: Nov 2004
Location: Down The Rabbit Hole
Posts: 7,979
i think cdc is cool. will i jump in on version 1.0? probably not.

I do have a question about this. am i wrong in remembering triggers use the row versioning thingie in the tempdb in 2008? does that ultimately read from the logs? same with CDC? I forget.

Again I think CDC is cool because of it's ease of use. i have not done any performance bench marking yet, but I strongly suspect a read is a read and a write is a write and unless CDC uses fewer reads, I am doubtful how much the perf will improve. cpu improvement maybe.

the other thing that might bother me about CDC is tieing your auditing to a specific platform.
__________________
software development is where smart people go to waste their lives

Last edited by Thrasymachus; 11-18-09 at 17:57.
Reply With Quote
  #7 (permalink)  
Old 11-19-09, 07:15
totaltech totaltech is offline
Registered User
 
Join Date: Nov 2009
Posts: 4
hello

Thank you for the information.

Can you give some useful guiled link where i can find information about the steps how to get CDC data?

Also if you have any statistic about the performance then it will be great.

One of my application required this feature but he is worring about the performance and scalability.

Thanks
Craig

Database Development Company San Diego
Reply With Quote
  #8 (permalink)  
Old 11-19-09, 10:55
blindman blindman is offline
World Class Flame Warrior
 
Join Date: Jun 2003
Location: Ohio
Posts: 11,726
Quote:
Originally Posted by dportas View Post
You would use triggers rather than CDC? Any particular reason other than familiarity?
Familiarity and control, but I will definitely look into CDC.
__________________
If it's not practically useful, then it's practically useless.

blindman
www.chess.com: "sqlblindman"
Reply With Quote
  #9 (permalink)  
Old 11-19-09, 13:54
Brett Kaiser Brett Kaiser is offline
Window Washer
 
Join Date: Nov 2002
Location: Jersey
Posts: 10,303
Quote:
Originally Posted by dportas View Post
Triggers introduce lots of complexity and frequently harm performance and make support and development more difficult.
Can I have a hit too?
__________________
Brett
8-)

It's a Great Day for America everybody!

dbforums Yak CorralRadio 'Rita
dbForums Member List
I'm Good Once as I ever was

The physical order of data in a database has no meaning.
Reply With Quote
  #10 (permalink)  
Old 11-19-09, 13:56
Brett Kaiser Brett Kaiser is offline
Window Washer
 
Join Date: Nov 2002
Location: Jersey
Posts: 10,303
__________________
Brett
8-)

It's a Great Day for America everybody!

dbforums Yak CorralRadio 'Rita
dbForums Member List
I'm Good Once as I ever was

The physical order of data in a database has no meaning.
Reply With Quote
  #11 (permalink)  
Old 11-19-09, 13:57
Brett Kaiser Brett Kaiser is offline
Window Washer
 
Join Date: Nov 2002
Location: Jersey
Posts: 10,303
Quote:
Originally Posted by blindman View Post
Familiarity and control, but I will definitely look into CDC.
I won't...just as I won't EVER employee CASCADE

And it's only in Enterprise Edition?

Know the cost difference?
__________________
Brett
8-)

It's a Great Day for America everybody!

dbforums Yak CorralRadio 'Rita
dbForums Member List
I'm Good Once as I ever was

The physical order of data in a database has no meaning.
Reply With Quote
  #12 (permalink)  
Old 11-19-09, 16:00
blindman blindman is offline
World Class Flame Warrior
 
Join Date: Jun 2003
Location: Ohio
Posts: 11,726
You're such a Luddite, Brett.
__________________
If it's not practically useful, then it's practically useless.

blindman
www.chess.com: "sqlblindman"
Reply With Quote
  #13 (permalink)  
Old 11-19-09, 16:13
Thrasymachus Thrasymachus is offline
SQL Server Street Fighter
 
Join Date: Nov 2004
Location: Down The Rabbit Hole
Posts: 7,979
dude, why do people hate cascade delete?

when you use it properly, it is physically more efficient and saves from having to write all those DELETE statements in the right order.

of course you should never use it where it does not make sense.
__________________
software development is where smart people go to waste their lives
Reply With Quote
  #14 (permalink)  
Old 11-19-09, 18:26
Brett Kaiser Brett Kaiser is offline
Window Washer
 
Join Date: Nov 2002
Location: Jersey
Posts: 10,303
Quote:
Originally Posted by blindman View Post
You're such a Luddite, Brett.
If ALL of these BS features were as good as a loom, I wouldn't have a problem...and, well, they mostly smoke and mirrors

Luddite - Wikipedia, the free encyclopedia

Why don't people like Cascade?

Because front end developers don't know what they are doing, and neither do the users

OOOOOPPPPSSS what HAPPEND to my data

Better have History tables to get the sheet back
__________________
Brett
8-)

It's a Great Day for America everybody!

dbforums Yak CorralRadio 'Rita
dbForums Member List
I'm Good Once as I ever was

The physical order of data in a database has no meaning.
Reply With Quote
  #15 (permalink)  
Old 11-19-09, 18:27
Brett Kaiser Brett Kaiser is offline
Window Washer
 
Join Date: Nov 2002
Location: Jersey
Posts: 10,303
Quote:
Originally Posted by Thrasymachus View Post
it is physically more efficient

OK, NOW you need to back THAT tidbit up with some facts
__________________
Brett
8-)

It's a Great Day for America everybody!

dbforums Yak CorralRadio 'Rita
dbForums Member List
I'm Good Once as I ever was

The physical order of data in a database has no meaning.
Reply With Quote
Reply

Tags
sql server 2008

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On