SQL Server 2005, you can't do this with SQL Server 2000.
You have a business requirement to audit all inserts, updates, and deletes from one or more tables within a database. The additional technical requirements are as follows:
1. The audit data must be logged into a single table within SQL Server, regardless the number or structure of the tables being audited
2. You have to log the name of the table, the time of the change, the user making the change, the image of the row changed (the data as inserted, the before and after image for an update, and the data in the row which was deleted)
3. Each audit record has to contain a flag indicating what type of change was made
4. With the exception of a sysadmin and the database owner of the database being audited, no one should have the ability to directly select, insert, update, or delete from the audit tables. Additionally, they should not even be able to view the definition of the audit tables or even know that they exist.
5. #4 has to be maintained even in the case where a DBA grants a user select, insert, update, or delete authority on the entire database being audiited. #4 must be maintained without requiring the DBA to revoke permissions from any user.
6. The DBA can not inadvertently allow access to the audit tables through ownership chains.
7. You can not use any external code base such as a 3rd party utility, tran log analyzer, SQL Server Profiler, or custom code. It has to be entirely self-contained within SQL Server and entirely implemented within T-SQL.
Since this is a real brain twister even if you've been using SQL Server 2005 for several years, let's up the ante a little. The best answer by Oct. 19th gets a p100 load. (Since I'm traveling on the 18th and 19th, it might take a couple of days to evaluate any last minute entries.) The solution has to have demo code and an explanation of why the specific feature choices were made. Enjoy!![Smile [:)]](/cs/emoticons/emotion-1.gif)
President - FilAm Software Technology, Inc
http://www.filamsoftware.com