如何找出更新的SQL Server选项

时间:2017-10-31 10:06:41

标签: sql-server

两天前,我们开始在执行存储过程的生产服务器上遇到问题。

在任何其他服务器上都没有问题,只有生产。

我们的调查发现服务器连接属性const React = require('react') const PropTypes = require('prop-types') import Reflux from 'reflux' const Radium = require('radium') class Map extends Reflux.Component { constructor(props) { super(props) this.loadJS = this.loadJS.bind(this) this.initMap = this.initMap.bind(this) } componentDidMount() { window.initMap = this.initMap; if (typeof google === 'object' && typeof google.maps === 'object') { this.initMap() } else { this.loadJS('https://maps.googleapis.com/maps/api/js?key=<API_KEY>&callback=initMap') } } // https://github.com/filamentgroup/loadJS/blob/master/loadJS.js loadJS(src) { var ref = window.document.getElementsByTagName("script")[0]; var script = window.document.createElement("script"); script.src = src; script.async = true; ref.parentNode.insertBefore(script, ref); } initMap() { var map = new google.maps.Map(this.refs.map, { center: {lat: -34.397, lng: 150.644}, zoom: 8 }) } render() { return (<div ref='map'></div>) } } module.exports = Radium(Map) 已设置为XACT ABORT,此选项仅在生产服务器上为ON

现在我们想要了解何时以及可能更改此选项的人。我们正在查看系统表,但到目前为止没有任何运气。

是否有人知道是否有办法?

3 个答案:

答案 0 :(得分:1)

1 /首先,看看这些值(将来复制它们):

SELECT * FROM sys.configurations

提出了一个解决方案here

2 /您是否曾尝试查看事件查看器?

3 /您是否尝试过查看SQL Server日志?

答案 1 :(得分:1)

我假设您指的是对user options位掩码配置值的更改(XACT_ABORT ON为16384)。此信息将记录到SQL Server错误日志中,并在默认跟踪中包含其他信息,这些信息可能与日期和时间相关。这些都是翻转文件,因此信息仅适用于最近的更改。

下面的T-SQL查询可以由sysadmin角色成员运行以获取此信息。

--get time of config change and before/after values from error log files
EXEC sp_readerrorlog 1,1,'configuration option';
EXEC sp_readerrorlog 2,1,'configuration option';
EXEC sp_readerrorlog 3,1,'configuration option';
EXEC sp_readerrorlog 4,1,'configuration option';
EXEC sp_readerrorlog 5,1,'configuration option';

--get more infromation (e.g. who made the change) from default trace
SELECT *
FROM (
    SELECT REVERSE(SUBSTRING(REVERSE(path), CHARINDEX('\', REVERSE(path)) , 255)) + 'log.trc'
    FROM sys.traces
    WHERE
        is_default = 1
    ) AS trace(path)
CROSS APPLY sys.fn_trace_gettable(trace.path, DEFAULT) AS trace_table
JOIN sys.trace_events AS te ON
    te.trace_event_id = trace_table.EventClass
WHERE te.name = 'errorlog'
ORDER BY trace_table.StartTime;

答案 2 :(得分:1)

  

现在我们想要了解何时以及可能更改此选项的人。

系统配置更改反映在SQL Server错误日志中。那么“何时”可以在那里找到:

exec xp_readerrorlog 0,1,N'Configuration option' -- change 1st parameter to search in previous logs

您将返回datetime + spid以及更改选项的说明。

您可以尝试在SQL Server默认跟踪中找到“who”,但它更频繁地被回收:

select tr.LoginName,
       tr.StartTime,
       tr.TextData
from sys.traces st 
     cross apply (select left(st.[path], len(st.[path]) - nullif(charindex('\', reverse(st.[path])), 0) + 1) + 'log.trc') t(p) 
     cross apply sys.fn_trace_gettable(t.p, default) tr 
where st.is_default = 1 and TextData like '%configur%'