摘要:下面的脚步可以为Get-ExtendedDate增加一个Member: GetWeekOfYearGet-ExtendedDate默认返回变量$a,也就是Get-Datefunction Get-ExtendedDate{ $a = get-date add-member -MemberType scriptmethod -name GetWeekOfYear ` -value {get-date -uformat %V} -inputobject $a $a } #end function Get-ExtendedDate #使用Get-ExtendedDate | Get-Mem...
阅读全文
摘要:# 获取最小的日期(通常用于做日期计算)Get-Date 0# 获取当前日期Get-Date# 获取当前日期的年(Get-Date).Year# 获取当前日期的月(Get-Date).Month# 获取当前日期的日(Get-Date).Day# 获取从今年起的天数(Get-Date).DayOfYear# 获取星期(Get-Date).DayOfWeek# 今年的第一天(Get-Date 0).AddYears((Get-Date).Year - 1)# 今年的最后一天(Get-Date 0).AddYears((Get-Date).Year).AddDays(-1)# 这个月的第一天(Get
阅读全文
摘要:之前有写过一篇:SQL Server 镜像证书过期处理 这是之前为替换证书做的测试准备,介绍了如何替换过期的镜像证书。而这篇文章则是对昨天的工作中进行了大量服务器的证书替换的时候碰到了一些问题,这里进行分析和总结。下面是在生产中操作的使用脚本:--脚本1select name, expiry_date from sys.certificates where issuer_name not like 'MS_%'godeclare @sql varchar(max)set @sql = ''select top 1 @sql = @sql + 'use m
阅读全文
摘要:SET XACT_ABORT的SQL语句执行情况演示:CREATE TABLE student( stuid int NOT NULL PRIMARY KEY, stuname varchar(50))CREATE TABLE score ( stuid int NOT NULL REFERENCES student(stuid), score int)GOINSERT INTO student VALUES (1,'a') INSERT INTO student VALUES (2,'b') INSERT INTO studen...
阅读全文
摘要:今天镜像中的主服务器进行维护重启,重启后发现镜像Disconnect,使用xp_readerrorlog 0, 1检查错误日志发现下列信息:Database mirroring connection error 5 'Connection handshake failed. The certificate used by this endpoint was not found: Certificate expired. Use DBCC CHECKDB in master database to verify the metadata integrity of the endpoint
阅读全文
摘要:当我们想要分析某些语句在一定数据量后的执行计划情况是可能会进行数据的模拟,伪造大量的数据。但其实这个工作挺费劲了,经朋友介绍在网上看到下面这种伪造统计信息的方式,对于如果只是分析执行计划的情况很方便。use tempdbgocreate table t1(i int, j int)gocreate table t2(h int, k int)goset statistics profile ongoselect distinct(i) from t1goselect * from t1, t2 where i = k order by j + kgoupdate statistics t1 w
阅读全文
摘要:create table test(username varchar(10), userinfo varchar(200), primary key (username) ) go --修改字段名 exec sp_rename 'test.userinfo', 'userdesc', 'column'; go sp_help test go --修改表名 exec sp_rename 'test', 'test1', 'object'; go sp_help test1 go --sp_rename
阅读全文
摘要:转:http://www.cnblogs.com/kerrycode/archive/2010/09/18/1830071.htmlSQL Server提供了专用管理员链接(DAC)。DAC允许管理员访问运行的服务器以执行诊断函数或Transact—SQL语句,或对服务器上的问题进行故障排除,即使服务器以锁定或在非正常状态下运行。DAC默认情况下只有服务器上可以使用DAC,但是你可以通过SQL Server 2005外围应用配置器设置允许远程计算机上的客户端应用程序使用DAC,如下图所示你也可以通过下面的SP_CONFIGURE命令更改数据库服务器配置--0-指明仅允许本地连接使用DAC--1
阅读全文
摘要:SQL Server is able to make implicit use of parallelism to speed SQL queries. Quite how it does it, and how you can be sure that it is doing so, isn't entirely obvious to most of us. Paul White begins a series that makes it all seem simple, starting at the gentle level of counting Jelly Beans
阅读全文
摘要:Transactional Replication ConversationsWhen troubleshooting Transactional Replication performance break down the flow of data into 4 simultaneous conversation.Examine performance of each conversation.This will help verify where the bottleneck investigation should begin.1)LogReaderReaderthread is rea
阅读全文
摘要:---查询索引操作的信息select * from sys.dm_db_index_usage_stats--查询指定表的统计信息(sys.stats和sysobjects联合查询)select o.name,--表名 s.name,--统计信息的名称 auto_created,--统计信息是否由查询处理器自动创建 user_created--统计信息是否由用户显示创建from sys.stats...
阅读全文
摘要:堆数据表是没有聚集索引的表。即数据行不按任何特殊的顺序存储,数据页也没有任何特殊的顺序。数据页不在链接列表内链接。sys.system_internals_allocation_units 系统视图中的列 first_iam_page 指向管理特定分区中堆的分配空间的一系列 IAM 页的第一页。SQL Server 使用 IAM 页在堆中移动。堆内的数据页和行没有任何特定的顺序,也不链接在一起。数...
阅读全文
摘要:解决数据库系统的性能问题可能是一项艰巨的任务。了解如何找到问题很重要,但是了解系统对特定请求作出特定反应的原因更加重要。影响数据库服务器上的 CPU 利用率 的因素有很多
阅读全文
摘要:必须重新生成系统数据库才能修复 master、model、msdb 或 resource 系统数据库中的损坏问题或者修改默认的服务器级排序规则。本主题提供如何重新生成系统数据库的分步说明。重新生成系统数据库之前重新生成 master、model、msdb 和 tempdb 系统数据库时,将删除这些数据库,然后在其原位置重新创建它们。如果在重新生成语句中指定了新排序规则,则将使用该排序规则设置创建系...
阅读全文
摘要:要查询系统DMV,请使用:sys.all_views要查询系统DMV字段,请使用:sys.syscolumns
阅读全文
摘要: or 和 union 测试结论:当都有索引时union效率更高, 3 如果没有索引or效率高因为:union 符合 SARG条件
阅读全文
摘要:1、提供有关如何在所有数据库中使用事务日志空间的统计信息。[代码]返回结果:代码2、显示当天数据库的日志文件[代码]返回结果:代码大家请注意看上个结果中master数据库日志文件的大小1.24mb 刚好是下面日志文件信息中FileSize的总和3、查询数据库文件的信息[代码]返回结果:代码大家可以看到这个结果基本可以替换sys.database_files,而且可以查询到整个实例的文件
阅读全文