-- Demostratin 2A (Using SQL Server Audit)
-- Step 1: Use the master database
USE master;
GO -- Step 2: Create a SQL Server Audit and define tis target as
-- application log
Create Server Audit MarketDevLog
To Application_log
With (QUEUE_DELAY = 1000, ON_FAILURE = CONTINUE)
GO -- Step 3: Change to the MarketDev database
USE MarketDev;
GO -- Step 4: Create a database audit specification for SELECT
-- activity on the Marketing schema
CREATE DATABASE AUDIT SPECIFICATION MrketingSelectSpec
FOR SERVER AUDIT MarketDevLog
ADD (SELECT ON SCHEMA::Marketing BY public);
GO -- Step 5: Query the sys.server_audits system view.
-- Scroll to the right and note the available columns.
-- particular, note the is_state_enabled column. SELECT * FROM sys.server_audits;
GO -- Step 6: Change to master database
USE master;
GO -- Step 7: Enable the server audit
ALTER SERVER AUDIT MarketDevLog WITH (STATE=ON);
GO -- Step 8: Change to MarketDev database
USE MarketDev;
GO -- Step 9: Enable the MarketingSelectSpec audit specification
ALTER DATABASE AUDIT SPECIFICATION MarketingSelectSpec
WITH (STATE = ON); -- Step 10: Query the sys.server_audits and
-- sys.database_audit_specifications and
-- sys.database_audit_specification_details system view
-- Note that the audit is now started and scroll to
-- see the details provided for the audit specification SELECT * FROM sys.server_audits;
SELECT * FROM sys.database_audit_specifications;
SELECT * FROM sys.database_audit_specification_details;
GO -- Step 11: Geenerate an auditable event by querying a table
-- in the Marketing schema. Also execute a query
-- that should not be audited. SELECT * FROM Marketing.PostalCode;
GO
SELECT * FROM DirectMarketing.City;
GO -- Step 12: Check the contents of the Application log
-- (Do this by Start, Right-click My Computer, then
-- Expand Diagnostics, Event Viewer, and Windows Logs
-- click Application. Click on each of the MSSQLSERVER
-- the upper pane For each evetn, click on the detail
-- the lower pane and review the contents). the close
-- management windows. -- Step 13: Change to the master database
USE master;
GO -- Step 14: Disable the server audit
ALTER SERVER AUDIT MarketDevLog WITH (STATE=OFF);
GO -- Step 15: Change to the MarketDev database
USE MarketDev;
GO -- Step 16: Disable the MarketingSelectSpec audit specification
ALTER DATABASE AUDIT SPECIFICATION MarketingSelectSpec
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. 使用Font Awesome替换你的网站图标(icons 图标)

    http://www.thinkcmf.com/font/icons/ 第一次使用 Font Awesome 发现相当的爽呀!它的图标很全,能够帮你节约时间去找图片.下面就来一起学习吧: 1: 去官方 ...

  2. RN项目中关于父子组件的通信

    子组件向父组件传递数据 子控件中在相应的函数中.通过props.coallback的回调通知父组件. 父组件调用callback属性时行 绑定,并在方法中去解析使用获取到的值 . //子控件: < ...

  3. 使用git提交代码到GitHub

    0.下载Git Bash,在Windows系统可以用Git Bash通过简单的命令将代码提交到GitHub1.打开项目所在的文件夹,右键,"Git Bash Here"2.初次使用 ...

  4. Linux Shell 文本处理工具集锦(转载)

    内容目录: find 文件查找 grep 文本搜索 xargs 命令行参数转换 sort 排序 uniq 消除重复行 用tr进行转换 cut 按列切分文本 paste 按列拼接文本 wc 统计行和字符 ...

  5. TZOJ 4839 麦森数(模拟快速幂)

    描述 形如2^P-1的素数称为麦森数,这时P一定也是个素数.但反过来不一定,即如果P是个素数,2^P-1不一定也是素数.到1998年底,人们已找到了37个麦森数.最大的一个是P=3021377,它有9 ...

  6. PAT 1048 数字加密(20)(代码+思路)

    1048 数字加密(20)(20 分) 本题要求实现一种数字加密方法.首先固定一个加密用正整数A,对任一正整数B,将其每1位数字与A的对应位置上的数字进行以下运算:对奇数位,对应位的数字相加后对13取 ...

  7. [SoapUI] 设置HTTP Request的Header

    import com.eviware.soapui.support.types.StringToStringMap def hearderMap = new StringToStringMap() d ...

  8. java.text.SimpleDateFormat的使用

    SimpleDateFormat 是一个以国别敏感的方式格式化和分析数据的具体类. 它允许格式化 (date -> text).语法分析 (text -> date)和标准化. Simpl ...

  9. ipconfig 查看本机IP地址

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

  10. Jfinal框架是什么框架?适用于什么项目呢?

    Jfinal框架是什么框架?适用于什么项目呢? jfinal 基于spring MVC研发的框架,操作简单.节省代码,适用于所有web项目.适合中小型项目开发.10分钟写出一个页面的增删改查.目前所在 ...