SQL Server数据库
OnlyQi
我是一只蜗牛
展开
-
Getting Started with SQL Server 2008 R2 Failover Clustering
SQL Server failover clustering provides high-availability support for an entire SQL Server instance. SQL Server failover clusters are built on top of Windows Server failover clusters. To create a SQL转载 2013-04-26 09:13:38 · 1637 阅读 · 0 评论 -
SQL Server常用链接
SQL Server中wait type的说明:http://msdn.microsoft.com/en-us/library/ms179984.aspx原创 2013-04-17 17:08:15 · 654 阅读 · 0 评论 -
如何查看曾经执行的SQL的执行计划
这篇文章讲述了如何从execution plan cache中取出里面的执行计划。注意如果memory不够用,旧的执行计划就会被清除出缓存,这样就无法查询到了。http://www.sqlservergeeks.com/blogs/AmitBansal/sql-server-bi/124/extracting-the-execution-plan-from-sql-server-plan-转载 2013-04-17 15:32:18 · 1396 阅读 · 0 评论 -
Reducing SQL Server CXPACKET Wait Type
文章对CXPACKET的解释比较简单易懂,但是对问题的解决解释的不到位。我认为最根本的方法就是修改SQL,使得SQL不会被拆分成过多的threads。In my last post, I wrote about how SQL Server schedules tasks to be executed. It’s important to be able to understan转载 2013-04-18 11:18:55 · 1671 阅读 · 0 评论 -
Execution Plan Basic
https://www.simple-talk.com/sql/performance/execution-plan-basics/Estimated execution plan uses the query processor tree and the statistics it has about the data, and applying the model, it work转载 2013-03-04 16:16:28 · 678 阅读 · 0 评论 -
图解SQL join方式
http://blog.sqlauthority.com/2009/04/13/sql-server-introduction-to-joins-basic-of-joins/转载 2013-04-26 16:59:23 · 716 阅读 · 0 评论 -
Disk Partition Alignment Best Practices for SQL Server
http://msdn.microsoft.com/en-us/library/dd758814.aspx转载 2013-05-06 16:40:36 · 840 阅读 · 0 评论 -
Parallel Query Processing
有时我们会在sysprocesses中看到很多duplicate SPID,但是有着不同的KPID。spid kpid------ ------55 376055 368455 595655 368055 3260这篇文章解释了这个现象:http://www.sqlservertorque.net/转载 2013-06-03 16:25:32 · 952 阅读 · 0 评论 -
使用SSIS将表导入其他数据库服务器
http://www.mssqltips.com/sqlservertip/2064/transfer-database-task-and-transfer-sql-server-objects-task-in-ssis/下面文章关于如何传递参数并在query window执行:http://www.mssqltips.com/sqlservertip/1395/pass-dynami转载 2013-06-21 11:43:19 · 1491 阅读 · 0 评论 -
SQL Server 2012 支持的升级版本
http://msdn.microsoft.com/en-us/library/ms143393.aspx转载 2013-07-08 14:27:54 · 1645 阅读 · 0 评论 -
SQL Server Latch & Debugging latch time out
http://mssqlwiki.com/2012/09/07/latch-timeout-and-sql-server-latch/转载 2013-07-14 15:45:12 · 970 阅读 · 0 评论 -
查询所有数据库数据文件的SQL
SELECT b.name,a.physical_nameFROM master.sys.master_files as a , sys.databases as bwhere a.database_id = b.database_idand a.physical_name not like '%.ldf'and b.name not in ('master','tempdb','msdb原创 2013-07-16 19:43:09 · 1323 阅读 · 0 评论 -
How to recover deleted data from SQL Server 暴强
http://raresql.com/2011/10/22/how-to-recover-deleted-data-from-sql-sever/不借助任何第三方工具即可从transaction log恢复被删除的数据。转载 2013-07-03 10:06:05 · 980 阅读 · 0 评论 -
两个读transaction log的工具
Pproduct that can read the transaction log like SQL Log Rescue or Apex SQL Log转载 2013-07-02 13:55:24 · 1145 阅读 · 0 评论 -
查询执行最慢的query的DMV
SELECT TOP 100 qs.total_elapsed_time / qs.execution_count / 1000000.0 AS average_seconds, qs.total_elapsed_time / 1000000.0 AS total_seconds, qs.execution_count, SUBSTRING (qt.text转载 2013-07-03 08:37:22 · 981 阅读 · 0 评论 -
Resource Governor
Resource Governor 可以将数据库负载根据用户要求,分散到自己可使用的资源中。从而限制不同的数据库访问程序可以使用的资源。例如有两个程序app1和app2分别使用数据库。使用Resource Governor可以让app1只能使用1颗cpu和1G内存,app2可以使用3颗cpu和2G内存。从而在程序层面上对其使用的资源进行监管。主要的概念有:Resou转载 2013-06-27 10:31:12 · 1409 阅读 · 0 评论 -
当SQL Server jobs失败时自动发送邮件
需要三个步骤:1,配置SQL Agent Mail。http://msdn.microsoft.com/en-us/library/ms186358.aspx在这个步骤中会配置profile,profile的email地址就是之后发送邮件的发件人。2,创建Operator。http://msdn.microsoft.com/en-us/library/ms175962%28原创 2013-06-26 09:40:11 · 2282 阅读 · 0 评论 -
使用statistics profile分析query的实际运行情况
使用statistics profile可以记录query实际运行的详细过程和统计信息。例如下面SQL可以记录存储过程每一步的运行情况和执行计划: SET STATISTICS PROFILE ONGO[dbo].[YouStoredProcedure]另外如果存储过程中使用了没有事先定义的临时表时,查看执行计划会报错。此时将执行计划关掉就可以了。SET SHOWPLA转载 2013-07-26 13:21:08 · 798 阅读 · 0 评论 -
使用Litespeed读取数据库事务日志
http://communities.quest.com/blogs/dbmanagement/2009/12/07/how-to-read-transaction-log-with-litespeed转载 2013-08-01 17:21:20 · 1078 阅读 · 0 评论 -
Concatenating Row Values in Transact-SQL 非常详细完全的解释和举例
https://www.simple-talk.com/sql/t-sql-programming/concatenating-row-values-in-transact-sql/转载 2013-09-18 10:41:18 · 815 阅读 · 0 评论 -
SQL Server 中的group by, rollup 和 grouping关键字的用法
GROUP BY groups the result set into summary rows by provided columns. For example, consider below data which contains sales figures by region.Group Name SalesYTD————转载 2013-09-18 10:20:29 · 2157 阅读 · 0 评论 -
查询缺失的索引
expensive queries querySELECT TOP 200 total_worker_time, execution_count , (total_worker_time /execution_count)/1000000 AS [Avg CPU Time seconds] ,CASE WHEN deqs.statement_start_offset原创 2013-09-25 15:57:30 · 3190 阅读 · 0 评论 -
将服务器上的所有数据库设置为simple恢复模式的SQL
USE masterGODECLARE @name VARCHAR(50) -- database nameDECLARE @recoveryMode VARCHAR(50) -- recovery modeDECLARE @sql NVARCHAR(500) DECLARE db_cursor CURSOR FORSELECT nameFROM master.dbo.sysda原创 2013-09-26 10:43:56 · 2284 阅读 · 0 评论 -
如何简单的分析SQL Server profiler 跟踪文件
http://msdn.microsoft.com/en-us/library/ff650699.aspx只需要按照文中To identify a long-running query from trace output一节,将数据导入数据库,然后按照文中提供的SQL语句就可以得到一个总结列表。简单的不能再简单了。转载 2013-10-12 15:35:49 · 1426 阅读 · 0 评论 -
SQL Formatter
总是遇到写得乱七八糟的SQL?或者copy SQL的时候格式都丢失了?其实google一下“SQL Formatter”就有很多网站在线转换SQL的格式。让SQL一目了然,节约DBA时间利器啊!!http://sqlformat.appspot.com/转载 2013-10-12 15:59:36 · 3934 阅读 · 1 评论 -
今天遇到的备份错误
今天备份数据库时失败了,错误是:VDI open failed due to requested abort. BACKUP LOG is terminating abnormally. BACKUP LOG cannot be performed because there is no current database backup.注意这几个error并非固定在一起。转载 2013-10-15 13:42:47 · 1906 阅读 · 0 评论 -
Ghost cleanup
Refer to http://social.msdn.microsoft.com/Forums/sqlserver/en-US/1409f597-2022-4c4c-ac5d-abaf91a7ec0c/problem-with-ghost-cleanuphttp://www.sqlskills.com/blogs/paul/turning-off-the-ghost-cleanup-task转载 2013-10-30 17:06:31 · 1749 阅读 · 0 评论 -
SQL SERVER – Get Database Backup History for a Single Database
USE AdventureWorksGO-- Get Backup History for required databaseSELECT TOP 100s.database_name,m.physical_device_name,CAST(CAST(s.backup_size / 1000000 AS INT) AS VARCHAR(14)) + ' ' + 'MB' AS bkSi转载 2013-11-05 10:15:35 · 1022 阅读 · 0 评论 -
恢复数据库时的Assembly错误
Msg 10314, Level 16, State 11, Line 52An error occurred in the Microsoft .NET Framework while trying to load assembly id 65536. The server may be running out of resources, or the assembly may not原创 2013-11-15 09:30:35 · 1456 阅读 · 0 评论 -
Deadlock troubleshooting
http://blogs.msdn.com/b/bartd/archive/2006/09/08/deadlock-troubleshooting_2c00_-part-1.aspxhttp://blogs.msdn.com/b/bartd/archive/2006/09/13/751343.aspxhttp://blogs.msdn.com/b/bartd/archive/200转载 2013-12-10 16:41:51 · 1116 阅读 · 0 评论 -
SQL Server 2008 - How to convert GMT(UTC) datetime to local datetime?
declare @InputUtcDateTime datetime2 = '2013-12-10 03:43:50'declare @LocalDateTime datetime2 = dateadd(minute, datepart(TZoffset, sysdatetimeoffset()), @InputUtcDateTime)print @LocalDateTime转载 2013-12-10 11:48:22 · 1291 阅读 · 0 评论 -
SQL server linked server 权限配置页面
http://technet.microsoft.com/en-us/library/ms188477(v=sql.105).aspx需要注意的是里面很多权限选项只针对SQL Server 权限认证,windows认证不可以。转载 2013-12-12 10:19:01 · 2244 阅读 · 0 评论 -
wrong @@SERVERNAME
http://msdn.microsoft.com/en-us/library/aa933172(v=sql.80).aspx转载 2013-12-12 17:10:35 · 939 阅读 · 0 评论 -
在2008 R2中set sp_send_dbmail attachment encoding
http://stackoverflow.com/questions/42703/sp-send-dbmail-attachment-encodingGena的回答。转载 2014-01-03 15:07:05 · 1310 阅读 · 0 评论 -
sp_send_dbmail fails when query uses linked server
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/4e6e8c6c-3cc6-4988-a60c-74e3b2b542f7/spsenddbmail-fails-when-query-uses-linked-server?forum=sqldatabaseengine这是一个bug转载 2013-12-20 16:47:35 · 1137 阅读 · 0 评论 -
使用sp_send_dbmail时指定字符集
USE [msdb]GO/****** Object: StoredProcedure [dbo].[sp_send_dbmail] Script Date: 01/14/2014 02:06:48 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER OFFGO-- sp_send_dbmail : Sends a mail fro转载 2014-01-14 15:08:07 · 2480 阅读 · 0 评论 -
SQL Server Error 18456: Finding the Missing Databases
http://www.mssqltips.com/sqlservertip/2581/sql-server-error-18456-finding-the-missing-databases/转载 2014-01-23 11:51:39 · 823 阅读 · 0 评论 -
关于Page Life Expectancy的一片文章
http://www.sqlskills.com/blogs/jonathan/finding-what-queries-in-the-plan-cache-use-a-specific-index/转载 2014-01-26 15:31:28 · 3044 阅读 · 0 评论 -
配置database mail的TSQL
First, execute below SQLs Rememberto change display name marked with RED inside the script l Enable SQL Server mailUSE masterGOsp_configure 'show advanced options',1GORECONFIGURE WI原创 2014-02-08 14:02:38 · 1540 阅读 · 0 评论 -
探测网络中存在的SQL Server实例的工具--Microsoft Assessment and Planning Toolkit
有时管理的SQL Server instance太多了,DBA会维护一个列表记录服务器的IP,用途等等情况。但是由于更新不及时或人为错误,会造成一定的混乱。甚至有一些人员自行在测试机上装一些SQL Server,DBA并不知道。如何了解网络内所有SQL Server的情况并将这些服务器纳入监管呢?介绍一个不错的工具Microsoft Assessment and Planning To转载 2014-02-08 11:21:55 · 1937 阅读 · 0 评论