大家好,我是考100分的小小码 ,祝大家学习进步,加薪顺利呀。今天说一说低版本sqlserver客户端连接高版本数据库_低版本sqlserver附加高版本数据库,希望您对编程的造诣更进一步.
帮人分析解决一个YourSQLDba备份报错问题,个人觉得有点意思,顺手记录一下分析思路,大体解决思路如下:
首先,找到YourSQLDba作业YourSQLDba_FullBackups_And_Maintenance的报错邮件或者作业的错误日志信息,检查YourSQLDba出错的详细信息。
YOURSQLDBA.MAINT.ShowHistoryErrors 96
发现YourSQLDba在更新统计信息是遇到错误,如下所示
<Exec>
代码100分
代码100分 <ctx>yMaint.UpdateStats</ctx>
<inf>update statistics selected</inf>
代码100分 <cmd>update statistics [model].[dbo].[ServiceBrokerQueue] WITH sample 100 PERCENT</cmd>
<err>Error 2706, Severity 16, level 6 : Table "ServiceBrokerQueue" does not exist.</err>
</Exec>
检查发现这个对象是queue,根本不是表,所以更新统计信息会出错。
那么YourSQLDba怎么会更新queue对象的统计信息呢?我首先检查了一下YourSQLDba的版本信息。当前数据库服务器上的YourSQLDba是相当老的一个版本了。然后我就去检查YourSQLDba的代码
Exec YourSQLDba.Install.PrintVersionInfo
========================================
YourSQLDba version: 5.0.2 2012-06-12
YourSQLDba更新统计信息是通过[yMaint].[UpdateStats]来更新统计,于是检查代码,发现获取要更新统计信息的对象是通过下面脚本获取的。首先将要更新统计信息的对象放到临时表#TableNames中去,然后生成更新统计信息的脚本。
-- makes query boilerplate with replacable parameter identified by
-- labels between "<" et ">"
-- this query select table for which to perform update statistics
truncate table #TableNames
set @sql =
"
set nocount on
;With
TableSizeStats as
(
select
object_schema_name(Ps.object_id, db_id("<DbName>")) as scn --collate <srvCol>
, object_name(Ps.object_id, db_id("<DbName>")) as tb --collate <srvCol>
, Sum(Ps.Page_count) as Pg
From
sys.dm_db_index_physical_stats (db_id("<DbName>"), NULL, NULL, NULL, "LIMITED") Ps
Group by
Ps.object_id
)
Insert into #tableNames (scn, tb, seq, sampling)
Select
scn
, tb
, row_number() over (order by scn, tb) as seq
, Case
When pg > 200001 Then "10"
When Pg between 50001 and 200000 Then "20"
When Pg between 5001 and 50000 Then "30"
else "100"
End
From
TableSizeStats
where (abs(checksum(tb)) % <SpreadUpdStatRun>) = <seqStatNow>
"
这个脚本会将queue类型的对象也放入临时表,所以明显是个Bug,不过YourSQLDba后续的版本已经Fix掉这个Bug了。如下所示,后续的版本就加上条件过滤了,只获取表和视图的数据。所以遇到这个问题,只需要升级YourSQLDba的版本就好了
-- makes query boilerplate with replacable parameter identified by
-- labels between "<" et ">"
-- this query select table for which to perform update statistics
truncate table #TableNames
set @sql =
"
Use [<DbName>]
set nocount on
;With
TableSizeStats as
(
select
object_schema_name(Ps.object_id) as scn --collate <srvCol>
, object_name(Ps.object_id) as tb --collate <srvCol>
, Sum(Ps.Page_count) as Pg
From
sys.dm_db_index_physical_stats (db_id("<DbName>"), NULL, NULL, NULL, "LIMITED") Ps
Where ( OBJECTPROPERTYEX ( Ps.object_id , "IsTable" ) = 1
Or OBJECTPROPERTYEX ( Ps.object_id , "IsView" ) = 1)
Group by
Ps.object_id
)
Insert into #tableNames (scn, tb, seq, sampling)
Select
scn
, tb
, row_number() over (order by scn, tb) as seq
, Case
When Pg > 5000001 Then "0"
When Pg between 1000001 and 5000000 Then "1"
When Pg between 500001 and 1000000 Then "5"
When pg between 200001 and 500000 Then "10"
When Pg between 50001 and 200000 Then "20"
When Pg between 5001 and 50000 Then "30"
else "100"
End
From
TableSizeStats
where scn is not null and tb is not null and (abs(checksum(tb)) % <SpreadUpdStatRun>) = <seqStatNow>
"
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
转载请注明出处: https://daima100.com/8567.html