Audit Drop Table

Jul 20, 2005

We would like to create a audit table for storing information if any
objects like tables / stored procedures are dropped.
Table would also contain information about time and the user name who
has dropped the object.
Any help would be great.

Thanks in advance.
Kamal

View 1 Replies


ADVERTISEMENT

Database Audit Specification To Audit Select On Certain User And Table

Nov 1, 2014

I have made a server security audit and specify from database audit specification to audit "select" on a certain user and on a certain table. I logged in by this user and made the select statement..when i run this query

"select * from sys.fn_get_audit_file('d:Auditaudit1*',null,null)"

It return a value at which time the query has done

after 15 minutes i repeated the same action, i run the audit query and the same result is showed off on the panel.is it suppose to return a list of values by how many times this user has made the select statement on that table ? for example at 5:00 pm then 6:00 pm and so on

View 1 Replies View Related

Drop All Indexes In A Table, How To Drop All For User Tables In Database

Oct 9, 2006

Hi,I found this SQL in the news group to drop indexs in a table. I need ascript that will drop all indexes in all user tables of a givendatabase:DECLARE @indexName NVARCHAR(128)DECLARE @dropIndexSql NVARCHAR(4000)DECLARE tableIndexes CURSOR FORSELECT name FROM sysindexesWHERE id = OBJECT_ID(N'F_BI_Registration_Tracking_Summary')AND indid 0AND indid < 255AND INDEXPROPERTY(id, name, 'IsStatistics') = 0OPEN tableIndexesFETCH NEXT FROM tableIndexes INTO @indexNameWHILE @@fetch_status = 0BEGINSET @dropIndexSql = N' DROP INDEXF_BI_Registration_Tracking_Summary.' + @indexNameEXEC sp_executesql @dropIndexSqlFETCH NEXT FROM tableIndexes INTO @indexNameENDCLOSE tableIndexesDEALLOCATE tableIndexesTIARob

View 2 Replies View Related

Create An Extra Table (for Audit Purpose) For Every Existing Table In A Database

Mar 28, 2008

Hi all, please help. I m trying to create an "empty" table from existing table for the audit trigger purpose.
For now, i am trying to create an empty audit table for every table in a database named "pubs", and it's seem won't work.
Please advise.. Thanks in advance.

Here is my code:





Code Snippet

USE pubs

DECLARE @TABLE_NAME sysname
DECLARE @AUDIT_TABLE VARCHAR(50)

SELECT @TABLE_NAME= MIN(TABLE_NAME) FROM INFORMATION_SCHEMA.TABLES
WHERE
TABLE_TYPE= 'BASE TABLE'
AND TABLE_NAME NOT LIKE 'audit%'
AND TABLE_NAME!= 'sysdiagrams'
AND TABLE_NAME!= 'Audit'
AND TABLE_NAME = 'sales'

WHILE @TABLE_NAME IS NOT NULL
BEGIN

SELECT @TABLE_NAME= MIN(TABLE_NAME) FROM INFORMATION_SCHEMA.Tables
WHERE TABLE_NAME> @TABLE_NAME
AND TABLE_NAME = 'sales'

SELECT @AUDIT_TABLE = 'Audit'+''@TABLE_NAME''


SELECT * INTO @AUDIT_TABLE
FROM @TABLE_NAME

TRUNCATE TABLE @AUDIT_TABLE
ALTER TABLE @AUDIT_TABLE ADD UserAction Char(10),AuditStartTime Char(50),AuditUser Char(50)


SELECT @TABLE_NAME= MIN(TABLE_NAME) FROM INFORMATION_SCHEMA.Tables
WHERE TABLE_NAME> @TABLE_NAME
AND TABLE_TYPE= 'BASE TABLE'
AND TABLE_NAME!= 'sysdiagrams'
AND TABLE_NAME!= 'Audit'
AND TABLE_NAME NOT LIKE 'audit%'

END
Thanks. ..

View 6 Replies View Related

Trigger On Table LeaveRegister And Inserting Rows In Audit Table

Oct 22, 2012

I write a insert trigger on my table LeaveRegister(1000 rows) and inserting rows in audit table, but when i inserting a row in LeaveRegister table. In audit table 1000 + 1 rows are inserting every time.

View 6 Replies View Related

Show Changes Between Records In Main Table And Audit Table

Aug 2, 2006

Hallo
i have two tables, MainTable and MainTableAudit: the second one keeps DML auditing via triggers.
I'm trying to build a query to highlight changes occurred to fields between the MainTable record and its audited records in MainTableAudit, for example, let's suppose i entered an item with some wrong attributes, and edited it three times:
MainTable record contains the latest and current version
ID002|Hitchhikers Guide to the Galaxy|Sci-fi|240 pages
MainTableAudit contains edited ID002 versions
ID002|Hitchhikers Guide to the Galaxy|Sci-fi|232 pages|2006-07-08 08:32:12
ID002|Hitchhikers Guide to the Galaxy|Sci-fi|212 pages|2006-05-08 10:54:02
ID002|Hitchhikers Guide to Galaxy|Sci-fi|222 pages|2006-07-04 11:42:16

I would like to build a report like this:
first insertion: Hitchhikers Guide to Galaxy|Sci-fi|222 pages
modified on 2006-07-04 11:42:16: field "Title" changed from "Hitchhikers Guide to Galaxy" to "Hitchhikers Guide to the Galaxy", field "PageNo" changed from "222" to "212"
modified on 2006-05-08 10:54:02: field "PageNo" changed from "212" to "232"
modified on 2006-07-08 08:32:12: field "PageNo" changed from "232" to "240"
current version: Hitchhikers Guide to the Galaxy|Sci-fi|240 pages

i'd prefer to use T-SQL and keep all into a single place (a view or storedprocedure), or at least to use reporting services; btw i would like to avoid coding web pages or hosted applications.

View 1 Replies View Related

Audit Logon / Audit Logoff Problem With SQL 2K

Jan 18, 2006

I need help...here is the problem.Last weekend, the servers in our datacenter where moved around. After thismove, and maybe coincidental, 1 server is performing very poor. Afterrunning a trace with SQL Profiler, I saw the problem which was laterconfirmed with another tool for SQL server performance monitoring. It seemsthat all connections to the SQL server (between 200 - 400) are doing a login/ logout for each command that they process. For example, the user'sconnection will login, perform a SELECT, and then logout. This is not a..NET application. The client software was not changed, it is still thesame. The vendor has said that it is not supposed to do that, it issupposed to use 1 connection that log's on in the morning and logs off atthe end of the day or whenever the user exits. 1 user may have severalconnections to the database.At times, the server is processing over 250 login / logouts (avgeraged for30 second period). Has anyone seen this problem? I have the server inAUDIT FAILUREs only. The server has become very unresponsive, things thattook 3 seconds now take over 15 seconds.Any ideas???

View 6 Replies View Related

Piping Data From A Table To An Audit Table

Nov 17, 2005

Lets say I have a table in which I want to audit, so I create a trigger for this table. Like

CREATE TRIGGER
on table
AFTER UPDATE
AS
INSERT INTO audittable (Changes Made to other table)
GO

How would I get the changes is all I'm asking.

View 1 Replies View Related

Default Table Owner Using CREATE TABLE, INSERT, SELECT && DROP TABLE

Nov 21, 2006

For reasons that are not relevant (though I explain them below *), Iwant, for all my users whatever privelige level, an SP which createsand inserts into a temporary table and then another SP which reads anddrops the same temporary table.My users are not able to create dbo tables (eg dbo.tblTest), but arepermitted to create tables under their own user (eg MyUser.tblTest). Ihave found that I can achieve my aim by using code like this . . .SET @SQL = 'CREATE TABLE ' + @MyUserName + '.' + 'tblTest(tstIDDATETIME)'EXEC (@SQL)SET @SQL = 'INSERT INTO ' + @MyUserName + '.' + 'tblTest(tstID) VALUES(GETDATE())'EXEC (@SQL)This becomes exceptionally cumbersome for the complex INSERT & SELECTcode. I'm looking for a simpler way.Simplified down, I am looking for something like this . . .CREATE PROCEDURE dbo.TestInsert ASCREATE TABLE tblTest(tstID DATETIME)INSERT INTO tblTest(tstID) VALUES(GETDATE())GOCREATE PROCEDURE dbo.TestSelect ASSELECT * FROM tblTestDROP TABLE tblTestIn the above example, if the SPs are owned by dbo (as above), CREATETABLE & DROP TABLE use MyUser.tblTest while INSERT & SELECT usedbo.tblTest.If the SPs are owned by the user (eg MyUser.TestInsert), it workscorrectly (MyUser.tblTest is used throughout) but I would have to havea pair of SPs for each user.* I have MS Access ADP front end linked to a SQL Server database. Forreports with complex datasets, it times out. Therefore it suit mypurposes to create a temporary table first and then to open the reportbased on that temporary table.

View 6 Replies View Related

Audit Table

Apr 18, 2008



I need to track all changes to my database at the application level. Say if anybody logs into the application with his user id and password, any add,delete,update should be tracked. This is an application with 5000 transactions a day. I thought of using a trigger on all the tables to capture the following fields.


[UserID]

[AuditDate]

[TableName]

[PrimaryKey]

[Action]

,PreviousValue]

[CurrentValue]

I thought of adding all the application user as a database user. So then userID will be SYSTEM_USER , and AuditDate will be GETDATE(). Is this a good idea?

I dono whether the field primarykey is really essential in my audit table? Please advice.

The field 'Action' will be update/delete/insert. Previous and Current value will be the entire record from the temp tables inserted and deleted in triggers. I dono whether this is a good idea to store the entire record or just the field which was changed or updated(as updates r gonna be more than insert and delete), and the entire record for insert and delete. Is that possible? We have columns_updated() in sql server 2005 where we can we find the columns which was updated. Will that work?

Can i capture all actions(inser/update/delete) in a trigger with FOR INSERT,UPDATE,DELETE ? If so, how can i update "ACTION" and implement something different for update(as discussed earlier) . Is there any other field which you think i should capture which might be important as a part of auditing or tracking.

Can we use trigger for all tables in the database at one time?

I know there are too many questions . I wud greatly appreciate any thoughts or help for any portion of it.

Thank You very much for your time,
Kayal

View 3 Replies View Related

Audit Table

Feb 21, 2008

I need to be able to audit the command Insert - Update - Delete sent to a table. I have attempted with a trigger but I have not been able to obtain the fields that have been upgraded.

It is possible to generate in the trigger the command Update - Insert - Delete sent?

thanks you.

David.

View 12 Replies View Related

How To Create An Audit Table

Aug 16, 2005

Can anyone help, I am able to create a trigger that will populate a audit table everytime one of my tables columns data changes, but I have an applications from another user that has a stored proceudre and when that is called from an application it hit the original table twice, so the audit table will get a duplicate entry.   How do you prevent an AUDIT TABLE from inserting a duplicate entry Here is my trigger:Create TRIGGER tg_audit_task_order_awardees on xxxfor INSERT,UPDATE,DELETE as
 INSERT INTO audit_task_order_awardees(  audit_log_type,  to_awardee,  solicitation_id,  contract_id,  order_number,  amount,  show_public,  audit_changedatetime,  audit_user)   Select  'OLD',  del.to_awardee,  del.solicitation_id,  del.contract_id,  del.order_number,  del.amount,  del.show_public,  getdate(),  del.modified_user FROM deleted del
 
/* for a new record */
 INSERT INTO audit_task_order_awardees(  audit_log_type,  to_awardee,  solicitation_id,  contract_id,  order_number,  amount,  show_public,  audit_changedatetime,  audit_user) Select   'NEW',  ins.to_awardee,  ins.solicitation_id,  ins.contract_id,  ins.order_number,  ins.amount,  ins.show_public,  getdate(),  ins.modified_user FROM inserted ins
 

View 1 Replies View Related

SSRS Audit Table

Apr 9, 2014

I'm trying to create and Audit report for different tables.I'd like to use an generic table structure for the report which will be temp.I was thinking something like this:

AuditID
,TableName
,FieldName
,OldValue
,NewValue
,DateAction
,UserName
,ActionType (update, insert, delete)

I've already created the audit table with same structure plus all field duplicated and action type. (this was a request)Now I need to group it for the report.following an example of audit table I've created

tblTest_audit
(
ID
ID_new
Name
Name_new
Address
Address_new
)

How can I fill my temp table?

View 1 Replies View Related

Audit Select On A Table?

Jul 20, 2005

Is there a way to audit 'select' on a given table;

View 1 Replies View Related

Looking For A Script To Audit User Table Rights

Sep 28, 2004

Hello everyone,

Does anyone know of a quick way to audit all users in a database and display their rights and permissions on a table level. I would hate to have to do it one user at a time. There has to be an easier way.

I'm going through a Sarbanes Oxley audit and need to provide them this information.

View 2 Replies View Related

Audit Table To Compare And Find Difference

Feb 10, 2015

I have a table called [dbo].[co_audit_trail]..All records that get changed in our software gets written to this table.

CREATE TABLE [dbo].[co_audit_trail](
[seq_no] [bigint] IDENTITY(1,1) NOT NULL,
[create_complete] [tinyint] NULL,
[user_name] [varchar](60) NULL,
[db_event] [varchar](16) NULL,
[date_of_change] [datetime] NULL,

[code]....

1. It looks like a 'ª' delimiters between fields. I need to pull out the second column in the above example it is - 9999999999. This is the place reference, so I need that in a separate field.
2. I need a way to compare the two fields and report back the change. So in the above example shows EAST. The After image shows WEST - I need the before image of EAST in one column and the WEST in another column.

View 5 Replies View Related

Trigger Is Deleting Entries In Audit Table?

Aug 30, 2013

The following is the trigger which create a row in the audit table when a single deletion is occurred.

ALTER TRIGGER [dbo].[TRG_Delete_tbl_attendance]
ON [dbo].[tbl_attendance]
AFTER DELETE
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.

[code]....

I am trying to create a trigger which should prevent the bulk deletion. The following is the trigger which I have written, it is preventing the bulk deletion. But the problem is, it is removing the single deletion entries in the audit table. I want audit table to hold back the single deletion entries without allowing the bult deletion

ALTER TRIGGER [dbo].[TRG_Delete_Bulk_tbl_attendance]
ON [dbo].[tbl_attendance]
AFTER DELETE
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

[code]....

View 1 Replies View Related

Create An Extra Table (for Audit Purpose)

Mar 28, 2008

Hi all, please help. I m trying to create an "empty" table from existing table for the audit trigger purpose.
For now, i am trying to create an empty audit table for every table in a database named "pubs", and it's seem won't work.
Please advise.. Thanks in advance.

Here is my code:


USE pubs

DECLARE @TABLE_NAME sysname
DECLARE @AUDIT_TABLE VARCHAR(50)

SELECT @TABLE_NAME= MIN(TABLE_NAME) FROM INFORMATION_SCHEMA.TABLES
WHERE
TABLE_TYPE= 'BASE TABLE'
AND TABLE_NAME NOT LIKE 'audit%'
AND TABLE_NAME!= 'sysdiagrams'
AND TABLE_NAME!= 'Audit'
AND TABLE_NAME = 'sales'

WHILE @TABLE_NAME IS NOT NULL
BEGIN

SELECT @TABLE_NAME= MIN(TABLE_NAME) FROM INFORMATION_SCHEMA.Tables
WHERE TABLE_NAME> @TABLE_NAME
AND TABLE_NAME = 'sales'

SELECT @AUDIT_TABLE = 'Audit'+''@TABLE_NAME''


SELECT * INTO @AUDIT_TABLE
FROM @TABLE_NAME

TRUNCATE TABLE @AUDIT_TABLE
ALTER TABLE @AUDIT_TABLE ADD UserAction Char(10),AuditStartTime Char(50),AuditUser Char(50)


SELECT @TABLE_NAME= MIN(TABLE_NAME) FROM INFORMATION_SCHEMA.Tables
WHERE TABLE_NAME> @TABLE_NAME
AND TABLE_TYPE= 'BASE TABLE'
AND TABLE_NAME!= 'sysdiagrams'
AND TABLE_NAME!= 'Audit'
AND TABLE_NAME NOT LIKE 'audit%'

END


Thanks. ..

View 3 Replies View Related

Delete Output Into &<xml Column Of Audit Table&>

Mar 31, 2008

Currently running Sql Server 2005Is it possible to issue the delete command and capture the affected rows asxml types that will be stored in an audit table with an xml column?Something along the lines of:delete from source_tableoutput(deleted.*into audit_table (xml_audit_column)for xml auto)where source_table.column = @delete_value

View 1 Replies View Related

Using Triggers To Track Changes In A Single Audit Table

Feb 6, 2006

Hi,

I am looking to track any changes made to any table within a db into a single audit table which will hold as fields: the table that has been updated/inserted, the field that was changed, its primary key, the old value and the new value specific to that field, and the date it was updated/inserted.

From what I have read, it does not look like this is possible with a trigger on table as it is not row specific and that I might have to control this from the business layer (vb.net). I am correct in this assumption, or is there a way of tracking specific data changes through triggers.

thanks

Welly

View 5 Replies View Related

Extract Strings From Search Path Column In Audit Table

Jul 22, 2013

I have a 'searchpath' column in audit table. I need to extract the folders from the column and display it in separate columns.

Column searchpath has value like:

//content/folder[@name='AFR']/folder?[@name='AFRABC']/folder[@name='CDD']/folder[@name='Packages'] /folder[@name='Deployment']/package[@name='XXX spend name']/model

I need to extract the folder names and display it in separate columns in a new table this way:

AFR AFRABC CDD Packages Deployment XXX spend name

View 6 Replies View Related

Trigger Doesn't Log Into The Audit Table If The Column Of Table Has Trigger On Is Null

Jan 23, 2008



Hi,

I have a trigger set on TABLE1 so that any update to this column should set off trigger to write to the AUDIT log table, it works fine otherwise but not the very first time when table1 has null in the column. if i comment out

and i.req_fname <> d.req_fname from the where clause then it works fine the first time too. Seems like null value of the column is messing things up

Any thoughts?


Here is my t-sql


Insert into dbo.AUDIT (audit_req, audit_new_value, audit_field, audit_user)

select i.req_guid, i.req_fname, 'req_fname', IsNull(i.req_last_update_user,@default_user) as username from inserted i, deleted d

where i.req_guid = d.req_guid

and i.req_fname <> d.req_fname



Thanks,
leo

View 7 Replies View Related

Integration Services :: Audit Logging In Table With Multiple OLEDB Destination And Command

Jun 5, 2015

In my package there are 10 DFT.

Each DFT have source > Tranformation > Conditionsplit > Rowcount_Transformation  >   Oledb Command
                                                                                
> Rowcount_Transformation1 >  Oledb Command1
                                                                                
> Rowcount_Transformation2 >  Oledb Command2
                                                                                
> Rowcount_Transformation3 >  Oledb Command3

All update hapend on diffrent Table.I want to log in Audit table .

My audit table like

Table_Name   Insert_count  Update_count

How can I log the package having multiple OLEDB Destination.

View 7 Replies View Related

Delete Or Drop Table Then Create Table

Mar 14, 2007

which one is smarter, where there is no indexing on the table which is really simple table delete everything or recreate table. I got an argument with one of my coworker. He says it doesnt matter i say do delete. Any opinions.

View 7 Replies View Related

Could Not Drop Table!

Jun 23, 2006

Hello !


I try to drop a table, but I get this message :

Could not drop object 'dbo.cs_Users' because it is referenced by a FOREIGN KEY constraint

This message does not tell me which is the Foreign key constraint so that I may disable it.

Any solution to force the dropping?

Thank you very much!

Regards,
Fabian

my favorit hoster is ASPnix : www.aspnix.com !

View 3 Replies View Related

Drop Table

Dec 29, 2006

hi, is it possible to recover the dropped table?
if means please tell me how.

View 3 Replies View Related

Drop Table Into??

Jan 14, 2008

hi everyone,

I have a couple questions. I'm very new to SQL and I have this problem:
I need to be able to drop the contents of Existingtable_B into Newtable_A - I found this command (below) that will make a 'copy' but I don't want to keep the contents of Existingtable_B. Is it possible to drop them into Newtable_A instead of copy? Also, I want to do this for 5 tables on Sundays at midnight.. how could I schedule that? Finally, what happens if there is not enough space or some other critical error happens during this procedure? I don't want to lose the data.

Any help is greatly appreciated.

View 4 Replies View Related

Why I Can't Drop A Table

Dec 12, 2005

Hi,When I drop a table in Sqlserver 2000 database, The following error occurs:Server: Msg 1204, Level 19, State 1, Line 1The SQL Server cannot obtain a LOCK resource at this time. Rerun yourstatement when there are fewer active users or ask the system administratorto check the SQL Server lock and memory configuration.What's wrong? Any help is greatly appreciated, thanks.

View 4 Replies View Related

Drop All Table

Jul 20, 2005

Hi everybody,I need some help in SQL Server. I am looking for a command that will "Dropall user table" in auser database.Can anyone help me?Thank you very muchSabrina

View 1 Replies View Related

Table Won't DROP

Jan 20, 2006

I am unable to get the table in the following VB code to actually DROP. A straight SQL version with literals (no variables) runs "successfully" as a query but the table also fails to DROP. Can anybody explain what I'm doing wrong?

  sSQL = ""
  sSQLExists = ""
  sSQLExists = "IF OBJECT_ID (N'ImEx.dbo." & TableName & "', N'U') IS NOT NULL"
  sSQLExists = sSQLExists & " DROP TABLE ImEx.dbo." & TableName & ";"
 
  sSQL = "CREATE TABLE [" & TableName & "] (" & sFieldInfo & ");"
  
  ConnectSQLExpress "ImEx.mdf"
  DbConn.Execute sSQLExists
  DbConn.Execute sSQL
  DbConn.Close

View 3 Replies View Related

Drop And Re-create Table

Jul 27, 2006

 
What kind of problems may I see if a process drop and re-create a set of tables every night?

View 1 Replies View Related

DROP TABLE If It Exists

Feb 9, 2008

 i am using vb.net and ms sql server 2005 express.....what is the syntax for dropping a table if existsi have used this but it says incorrect syntax near if Dim cmda As New SqlCommand("drop table " + test + " if exists", New SqlConnection(strdb)) cmda.Connection.Open()        cmda.ExecuteNonQuery()       cmda.Connection.Close()any solutions???? plz only answer in vb.net and sql server express

View 8 Replies View Related

Cannot Drop Temporary Table

Apr 30, 2008

I'm trying to drop a temporary table.  I keep getting this error:
Cannot drop the table '#temp_table', because it does not exist in the system catalog.
I tried the following but it did not work, so help would be appreciated.
if object_id('tempdb..#temp_table') is not nulldrop table #temp_table

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved