1. -- Demostratin 2A (Using SQL Server Audit)
  2. -- Step 1: Use the master database
  3. USE master;
  4. GO
  5.  
  6. -- Step 2: Create a SQL Server Audit and define tis target as
  7. -- application log
  8. Create Server Audit MarketDevLog
  9. To Application_log
  10. With (QUEUE_DELAY = 1000, ON_FAILURE = CONTINUE)
  11. GO
  12.  
  13. -- Step 3: Change to the MarketDev database
  14. USE MarketDev;
  15. GO
  16.  
  17. -- Step 4: Create a database audit specification for SELECT
  18. -- activity on the Marketing schema
  19. CREATE DATABASE AUDIT SPECIFICATION MrketingSelectSpec
  20. FOR SERVER AUDIT MarketDevLog
  21. ADD (SELECT ON SCHEMA::Marketing BY public);
  22. GO
  23.  
  24. -- Step 5: Query the sys.server_audits system view.
  25. -- Scroll to the right and note the available columns.
  26. -- particular, note the is_state_enabled column.
  27.  
  28. SELECT * FROM sys.server_audits;
  29. GO
  30.  
  31. -- Step 6: Change to master database
  32. USE master;
  33. GO
  34.  
  35. -- Step 7: Enable the server audit
  36. ALTER SERVER AUDIT MarketDevLog WITH (STATE=ON);
  37. GO
  38.  
  39. -- Step 8: Change to MarketDev database
  40. USE MarketDev;
  41. GO
  42.  
  43. -- Step 9: Enable the MarketingSelectSpec audit specification
  44. ALTER DATABASE AUDIT SPECIFICATION MarketingSelectSpec
  45. WITH (STATE = ON);
  46.  
  47. -- Step 10: Query the sys.server_audits and
  48. -- sys.database_audit_specifications and
  49. -- sys.database_audit_specification_details system view
  50. -- Note that the audit is now started and scroll to
  51. -- see the details provided for the audit specification
  52.  
  53. SELECT * FROM sys.server_audits;
  54. SELECT * FROM sys.database_audit_specifications;
  55. SELECT * FROM sys.database_audit_specification_details;
  56. GO
  57.  
  58. -- Step 11: Geenerate an auditable event by querying a table
  59. -- in the Marketing schema. Also execute a query
  60. -- that should not be audited.
  61.  
  62. SELECT * FROM Marketing.PostalCode;
  63. GO
  64. SELECT * FROM DirectMarketing.City;
  65. GO
  66.  
  67. -- Step 12: Check the contents of the Application log
  68. -- (Do this by Start, Right-click My Computer, then
  69. -- Expand Diagnostics, Event Viewer, and Windows Logs
  70. -- click Application. Click on each of the MSSQLSERVER
  71. -- the upper pane For each evetn, click on the detail
  72. -- the lower pane and review the contents). the close
  73. -- management windows.
  74.  
  75. -- Step 13: Change to the master database
  76. USE master;
  77. GO
  78.  
  79. -- Step 14: Disable the server audit
  80. ALTER SERVER AUDIT MarketDevLog WITH (STATE=OFF);
  81. GO
  82.  
  83. -- Step 15: Change to the MarketDev database
  84. USE MarketDev;
  85. GO
  86.  
  87. -- Step 16: Disable the MarketingSelectSpec audit specification
  88. ALTER DATABASE AUDIT SPECIFICATION MarketingSelectSpec
  89. WITH (STATE = OFF);

Microsoft SQL Server 2012 管理 (2): Auditing的更多相关文章

  1. Microsoft SQL Server 2012 管理 (1): 安装配置SQL Server 重点

    SQL Server 可以在实例,数据库,列,查询分别指定排序规则 /* Module 1 - working with Clollations */ -- 1.1 Obtain the Instan ...

  2. Microsoft SQL Server 2012 管理 (2): 实例与数据库管理

    1.加密数据库 /* Module 2 Implementing Transparent Data Encryption */ -- 2.1 Create DataBase Master Key US ...

  3. Querying Microsoft SQL Server 2012 读书笔记:查询和管理XML数据 1 -使用FOR XML返回XML结果集

    XML 介绍 <CustomersOrders> <Customer custid="1" companyname="Customer NRZBB&qu ...

  4. 【转】Microsoft® SQL Server® 2012 Performance Dashboard Reports

    http://www.cnblogs.com/shanyou/archive/2013/02/12/2910232.html SQL Server Performance Dashboard Repo ...

  5. Microsoft SQL server 2012数据库学习总结(一)

    一.Microsoft SQL Server2012简介 1.基本概要 Microsoft SQL Server 2012是微软发布的新一代数据平台产品,全面支持云技术与平台,并且能够快速构建相应的解 ...

  6. 微软推出的免费新书《Introducing Microsoft SQL Server 2012》

    微软推出的免费新书<Introducing Microsoft SQL Server 2012>,该书详细介绍微软SQL 2012数据库服务最新功能以及功能应用和使用技巧. 该书适合SQL ...

  7. Exam 70-462 Administering Microsoft SQL Server 2012 Databases 复习帖

    好吧最近堕落没怎么看书,估计这个月前是考不过了,还是拖到国庆之后考试吧.想着自己复习考试顺便也写点自己的复习的概要,这样一方面的给不准备背题库的童鞋有简便的复习方法(好吧不被题库的同学和我一样看MSD ...

  8. Microsoft® SQL Server® 2012 功能包

    Microsoft® SQL Server® 2012 功能包 http://www.microsoft.com/zh-cn/download/details.aspx?id=29065 Micros ...

  9. sql server 安装出现需要sqlncli.msi文件,错误为 microsoft sql server 2012 native client

    在安装sql server 2017 时出现 弹框标题为  microsoft sql server 2012 native client  内容为需要sqlncli.msi文件 去本地目录找本身的那 ...

随机推荐

  1. spring jpa exists

    Subquery<A> subquery = criteriaQuery.subquery(A.class);Root<A> root1 = subquery.from(A.c ...

  2. 带图标的input

    <style> .text{ border:solid 2px #ccc; width:400px; height:40px; background:url(http://d.lanren ...

  3. 84直方图最大矩形覆盖 · Largest Rectangle in Histogram

    [抄题]: Given n non-negative integers representing the histogram's bar height where the width of each ...

  4. 4sum, 4sum closest

    4sum [抄题]: [思维问题]: 以为很复杂,其实是“排序+双指针”的最高阶模板 [一句话思路]: [输入量特别大怎么办]: [画图]: [一刷]: 先排序! if (i > 0 & ...

  5. 苹果 重置APPID密保问题及更新开发者协议

    [链接]重置AppleID密保问题 https://www.jianshu.com/p/37e7f2852eda [链接]苹果开发者计划许可协议更新:持续更新 https://www.jianshu. ...

  6. [leetcode]381. Insert Delete GetRandom O(1) - Duplicates allowed常数时间插入删除取随机值

    Design a data structure that supports all following operations in average O(1) time. Note: Duplicate ...

  7. Kuberentes-入门

    一.kubernetes架构介绍和集群规划 点击链接查看: 系统环境初始化:https://www.cnblogs.com/hwlong/p/9105742.html 二.CA证书创建和分发 点击链接 ...

  8. centos7下源码安装mysql5.7.16

    一.下载源码包下载mysql源码包 http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.16.tar.gz 二.安装约定: 用户名:mysql 安装目录 ...

  9. jquery获取radio单选框的值

    1.获取原有单选框的值 var value=$("input[name='is_setting']:checked").val(); 2.获取重选后的单选框的值 <tr> ...

  10. ipconfig 查看本机IP地址

    打开cmd 窗口 然后输入ipconfig 就会为你展示你想要的IP地址了...