ITPub博客

首页 > 数据库 > SQL Server > 通过union all把sql查询的结果拼接起来

通过union all把sql查询的结果拼接起来

原创 SQL Server 作者:ywxj_001 时间:2017-10-25 00:40:55 0 删除 编辑
SELECT distinct server_principal_name,object_name,event_time
FROM sys.fn_get_audit_file('\\10.0.0.100\Ad\Audit_DDL_678FA9A7-018F-4280-97C7-FD1861CAB760.sqlaudit ', NULL, NULL)
WHERE database_name = 'HR'and action_id='CR' and  class_type='U'  
union all
SELECT distinct server_principal_name,object_name,event_time
FROM sys.fn_get_audit_file('\\10.0.0.100\Ad\Audit_DDL_678FA9A7-018F-4280-97C7-FD1861CAB760.sqlaudit ', NULL, NULL)
WHERE database_name = 'HR'and action_id='CR' and  class_type='U' 
union all
SELECT distinct server_principal_name,object_name,event_time
FROM sys.fn_get_audit_file('\\10.0.0.100\Ad\Audit_DDL_678FA9A7-018F-4280-97C7-FD1861CAB760.sqlaudit ', NULL, NULL)
WHERE database_name = 'HR'and action_id='CR' and  class_type='U'

把查询出来的server_principal_name,object_name,event_time三个字段的结果拼接起来。

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/22996654/viewspace-2146329/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
在零售、金融、互联网行业从事数据库相关工作10余年,有丰富的数据库管理和架构的相关经验。 涉及SQLServer、Oracle、MySQL、PostgreSQL等多种数据库。 目前在一家互联网公司担任DBA经理。 负责整个集团数据库的架构设计和管理工作。

注册时间:2010-01-19

  • 博文量
    247
  • 访问量
    436205