Auditing in SQL server

AID: 8399
  • Status: Published

2560 points

  • ByPatelAlpesh
  • TypeGeneral
  • Posted on2011-10-25 at 04:31:18
Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days.

Lets' understand the Audit to know the usage of data and operation on data.

Please follow the steps below and make sure Audit is not available in Standard and Express edition of SQL Server.

Note: Server Audit Configuration will find at Server=> Security=>Audit
and
Database Audit Configuration will find at Server=> Database=> Security=> Database Audit Specification

1. Set the Proper Audit name and Select the Audit location type, (File, Security and Application Log etc.)
 
Audit-Server.png
  • 104 KB
  • Server Setting
Server Setting


Based on the Audit type may you have question why audit is not at SQL Table level? A simple answer is when audit is enabled and change is recorded then again due to the insertion of that log cyclic insertion occur. that's why audit is not available to save in SQL table.

2. Audit Type is selected as File then select the folder path.
AuditType.png
  • 72 KB
  • Audit Location
Audit Location


3. Same thing you can create for Server Audit Specification.
 
Servver-specification.png
  • 156 KB
  • Server Audit Specification
Server Audit Specification


In this step you have predefined options provided by SQL and you can use any of that for your purpose.

i.e If you want to change the permission to data etc. Please make sure you can find the Server and Database level actions.

4. Create Audit Action on particular object (Database objects like Table, View etc.)
 
DAtabase-specification.png
  • 181 KB
  • Database Specification
Database Specification


5. Select Option from Action drop down and before that Select the Audit source as shown in below image.
Audit-Table.png
  • 56 KB
  • Object Config
Object Config


That's it for Configure the Server/Database Audit.

Let's see the result of Audit how can we see the result of audit. Who has viewed the data, updated data or deleted data etc. etc.

For, this SQL provide the Management function to read the Audit files and give result step by step.

SELECT
* FROM fn_get_audit_file(
'H:\PefLogs\Audit-FailedLogin_6A8681AA-5555-4EA9-AA18-D18A552E1ACF_0_129216903300500000.sqlaudit',
default
, default)
                                    
1:
2:
3:
4:
5:

Select allOpen in new window



After executing this log you can get the result as below:
Untitled.png
  • 22 KB
  • Result
Result
    Asked On
    2011-10-25 at 04:31:18ID8399
    Tags

    Audit

    ,

    SQL Server

    Topic

    MS SQL Server

    Views
    1636

    Comments

    Expert Comment

    by: paulop1975 on 2011-11-01 at 12:15:00ID: 32965

    Truth! This is indeed a very useful article, since many IT teams tend to, themselves, forget a bit about auditing issues. By my experience, this resource only becomes useful when it isn't used, so there's no harm in setting it up.
    Thanks,
    PP

    Add your Comment

    Please Sign up or Log in to comment on this article.

    Join Experts Exchange Today

    Gain Access to all our Tech Resources

    Get personalized answers

    Ask unlimited questions

    Access Proven Solutions

    Search 3.2 million solutions

    Read In-Depth How-To Guides

    1000+ articles, demos, & tips

    Watch Step by Step Tutorials

    Learn direct from top tech pros

    And Much More!

    Your complete tech resource

    See Plans and Pricing

    30-day free trial. Register in 60 seconds.

    Loading Advertisement...

    Top MS SQL Server Experts

    1. jogos

      246,566

      Guru

      1,668 points yesterday

      Profile
      Rank: Sage
    2. acperkins

      246,249

      Guru

      1,000 points yesterday

      Profile
      Rank: Genius
    3. lcohan

      194,990

      Guru

      2,000 points yesterday

      Profile
      Rank: Genius
    4. anujnb

      179,525

      Guru

      2,000 points yesterday

      Profile
      Rank: Wizard
    5. ScottPletcher

      154,405

      Guru

      6,500 points yesterday

      Profile
      Rank: Genius
    6. matthewspatrick

      131,392

      Master

      1,620 points yesterday

      Profile
      Rank: Savant
    7. ValentinoV

      126,429

      Master

      1,800 points yesterday

      Profile
      Rank: Genius
    8. EugeneZ

      120,790

      Master

      2,000 points yesterday

      Profile
      Rank: Genius
    9. TempDBA

      112,141

      Master

      1,168 points yesterday

      Profile
      Rank: Sage
    10. angelIII

      100,133

      Master

      0 points yesterday

      Profile
      Rank: Elite
    11. HainKurt

      93,046

      Master

      0 points yesterday

      Profile
      Rank: Genius
    12. mwvisa1

      88,585

      Master

      40 points yesterday

      Profile
      Rank: Genius
    13. dtodd

      88,114

      Master

      0 points yesterday

      Profile
      Rank: Genius
    14. huslayer

      81,392

      Master

      0 points yesterday

      Profile
      Rank: Sage
    15. ralmada

      75,583

      Master

      400 points yesterday

      Profile
      Rank: Genius
    16. BCUNNEY

      74,206

      Master

      0 points yesterday

      Profile
      Rank: Guru
    17. dqmq

      66,272

      Master

      0 points yesterday

      Profile
      Rank: Genius
    18. rajeevnandanmishra

      60,246

      Master

      2,000 points yesterday

      Profile
      Rank: Guru
    19. dbaduck

      58,208

      Master

      2,000 points yesterday

      Profile
      Rank: Sage
    20. CodeCruiser

      55,120

      Master

      0 points yesterday

      Profile
      Rank: Genius
    21. Qlemo

      53,598

      Master

      2,000 points yesterday

      Profile
      Rank: Genius
    22. ryanmccauley

      52,252

      Master

      0 points yesterday

      Profile
      Rank: Sage
    23. Cluskitt

      50,880

      Master

      800 points yesterday

      Profile
      Rank: Wizard
    24. sdstuber

      50,836

      Master

      0 points yesterday

      Profile
      Rank: Genius
    25. mark_wills

      49,374

      10 points yesterday

      Profile
      Rank: Genius

    Hall Of Fame