透過union all把sql查詢的結果拼接起來

ywxj_001發表於2017-10-25
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部落格 ” ,連結:http://blog.itpub.net/22996654/viewspace-2146329/,如需轉載,請註明出處,否則將追究法律責任。

相關文章