How can I do dml auditing on SQL server? - sql-server

Is there any way to do auditing for DML on sql server ??
Appreciate the help that I can get since there is a problem with data that I need to figure out which user that do manipulate the data on various tables , so need to activate the dml audit to include all of the tables in my schema or if possible the database
Regards,

I guess that I fogot to mention that we have sql server 2008 , so I found that most of the features were introduced to 2012 and above , so the solution found is:
CREATE DATABASE AUDIT SPECIFICATION referring to the link
https://msdn.microsoft.com/en-us/library/cc280404.aspx
Regards,
thank you all

Related

Find Last Modifcation Time of Filegroup Option in SQL Server

I searched almost everywhere but I couldn't find a solution.
I'm looking for a way to find the last time that user change an option of a filegroup in SQL Server database.
For example, the last time of changing read-only property of a specific filegroup.
Is there any way?
Thanks :)
Thanks for your comments, SQL Server Audit Log solved my problem.
These link about SQL Server Auditing were helpful for me:
Setup SQL Server Audit:
https://solutioncenter.apexsql.com/how-to-setup-and-use-sql-server-audit-feature/
https://learn.microsoft.com/en-us/sql/relational-databases/security/auditing/sql-server-audit-database-engine?view=sql-server-2017
Read SQL Server Audit Information:
https://solutioncenter.apexsql.com/analyze-and-read-sql-server-audit-information/

Migrating from SQL Server 2005 to SQL Server 2008 : forced to use schema name before table name

I have a two big programs that connect to a SQL Server 2005 database.
Now we will migrate to a new server with SQL Server 2008.. the programs don't work anymore when connected to the new server, the cause is that in all the queries in the programs only table names are used, and they are not dbo tables.. so SQL Server 2008 doesn't recognise them, unless I use the schema name before the table name...
It is very very difficult for me to change all the queries in the two programs to add the schema name before the tables names.
I read in this forum that if I specify the default schema the problem will be solved.. but it haven't been solved though.
The only solution that seems to be working is when I changed the schema of the table to dbo.. but I am not sure if this action will be OK or will it cause some other problems related to this modification?
Is there any better solution?
Will changing the schema of the tables cause me other kind of problems?
Many thanks in advance
Default schemea will work for you. What are the issue with this approach?
Change schema name will cause a big issue and not advisable. Where and how much schema name change?(just think).
You just set a default schema with only one procedure first and check, if this is ok. then change the whole database schema.
https://dba.stackexchange.com/questions/21158/net-sql-server-authentication-schema-issue
In sql server 2005, how do I change the "schema" of a table without losing any data?
Change Schema Name Of Table In SQL
Best practice for SQL Server 2008 schema change

Insert Access 2003 table data into SQL Server 2008

I need to insert data from access 2003 table (only some columns) into sql server 2008 table.
Please reply if anyone knows how to connect to the sql server from access and do the above functionlity.
A great thanks in advance.
Regards,
Karthik
If you are not trying to import, rather trying to actually maintain though access, then linked tables is the best approach in my opinion.
A linked table allows you to connect to many different types of sources, read, update, delete depending on permissions.

Is there an elegant way to track the modification of all columns of one table in SQL Server 2008

There is a table in my database containing 100 columns. I want to create a trigger to audit the modification for every update operation.
What I can think is to create the update clause for all columns but they are all similar scripts. So is there any elegant way to do that?
Check Change Data Capture
Update
CDC provides tracking of all details of changes. Available since SQL Server 2008.
(Change data capture is available only on the Enterprise, Developer, and Evaluation editions of SQL Server.
Source: http://msdn.microsoft.com/en-us/library/bb522489.aspx)
More lightweight solution is Change Tracking (Sync Framework), the one code4life mentioned before, available since SQL Server 2005.
Update2:
Related questions (with a lot of sublinks):
History tables pros, cons and gotchas - using triggers, sproc or at application level
History tables pros, cons and gotchas - using triggers, sproc or at application level
Suggestions for implementing audit tables in SQL Server?
Suggestions for implementing audit tables in SQL Server?
Are soft deletes a good idea?
Are soft deletes a good idea?
How do I version my MS SQL database in SVN?
Versioning SQL Server database
Thomas LaRock. SQL Server Audit: Magic without a Wizard
http://www.simple-talk.com/sql/database-administration/sql-server-audit-magic-without-a-wizard/
There's this resource on MSDN which you might find helpful:
Tracking Changes in the Server Database (including SQL Server 2008)
I'm not sure if you're using SQL Server 2008 though.
Code generation?
Have you looked at the techniques which http://autoaudit.codeplex.com/ uses?
Theoretically, you can use 1 trigger and check COLUMNS_UPDATED() to know which columns has changed.
(not be tested)
See more here

Same as "Trigger to update data on another SQL Server" but in SQL Server 2000

I have the same question to ask, but I'm using both SQL 2000 Server.
When the table1 in SQL Server 2000 gets updated/inserted/deleted, I have to update another table in SQL Server 2000. How is it possible to achieve that ?
Thanks in advance
Check out: SQL 2000 Triggers.
You should be able to create a SQL Triggers.
I would recommend downloading/install the SQL 2000 SP4. See SP 4 Enhancements - See FIX 884855 .
The accepted answer of the original question does not refer to any version specific features of MSSQL.
Linked servers are also supported in MSSQL 2000.
That's what triggers are for, so yes you can do that. The biggest thing to remember if you haven't written a trigger before is that the trigger fires on the whole batch nor row-by-row, so all code to insert to another table must be set-based not row-based.
To be more specifc as to the code code you need to write the trigger we would need more details as to waht you want to do. Are you creating an audit table? Are you creating a child record? PLease show the details of data going into table1 and what data you would expect the trigger to put into table2 as a result.

Resources