https://blogs.msdn.microsoft.com/askjay/2009/12/29/basic-debugging-concepts-and-setup/


You can create a memory dump of the SQL Server process space in several ways.  There are many external tools that can help you accomplish this such as userdump.exe, debugdiag.exe, and ADPlus.exe.  In this post, I’ll cover 3 common ways to accomplish this for SQL Server:  The most common way (sqldumper), using the debugger, and three methods from within SQL Server itself.

First, two of these methods will require that you get the process id (PID) of SQL Server.   Here are a few simple ways to do that:

1.  From a command window, execute –> tasklist | find /i “sqlservr” or from the Debugging tools directory execute –> tlist | find /i “sqlservr”

2.  Open task manager, and find sqlservr.exe and get the PID from the PID column.  If you don’t see this column, then select View –> Select Columns to add it.

3.  In a query window inside of SSMS on the instance you wish to dump, execute –> “SELECT SERVERPROPERTY(‘PROCESSID’)

4.  Get the process ID from the SQL Server Errorlog.

Now that you have the PID, you can use one of the following ways to create the dump:

Method 1 (Using SqlDumper)

The most common way (and the way used internally by SQL Server) is to run SqlDumper.exe.   You will find SqlDumper.exe in the following directory for a default installation of SQL Server:

C:\Program Files\Microsoft SQL Server\100\Shared

The syntax of SqlDumper is as follows:

SqlDumper <process id (PID)> <thread id (TID)> <Flags:Minidump Flags> <SQLInfoPtr> <Dump Directory>

more parameters can be seen with SqlDumper /?

The common flags are as follows:

0x0120 – Minidump (this is a dump of just the stacks and loaded modules – this is the smallest of the dump types – this is normally the type of dump created automatically by SQL Server during AVs and other exceptions)

0x01100 – Full Dump (this dumps the entire process space – this can be very large on a 64 bit system or any system with a large amount of memory assigned to SQL Server)

0x8100 – Filtered Dump (a filtered dump is a dump of all of Stolen Memory plus certain areas of the buffer pool)

NOTICE:  SQLDumper can be used to dump ANY user mode process – not just SQL Server.

Some examples for SQLServer running under SPID 4024 to c:\temp:

Minidump:  sqldumper 4024 0 0x0120 0 c:\temp 
Full Dump:  sqldumper 4024 0 0x01100 0 c:\temp 
Filtered Dump:  sqldumper 4024 0 0x8100 0 c:\temp

The dump file will have the naming convention of:   SQLDmpr####.mdmp (i.e.  SQLDmpr0001.mdmp)

Method 2 (Using a debugger)

To dump SQL Server from WINDBG or other debugger, attach the debugger to the process using the PID:

Once connected, just use the .dump command which has the following syntax:

Options are: 
  /a – Create dumps for all processes (requires -u) 
  /b[a] – Package dump in a CAB and delete dump 
  /c <comment> – Add a comment (not supported in all formats) 
  /j <addr> – Provide a JIT_DEBUG_INFO address 
  /f – Create a legacy style full dump 
  /m[acdfFhiprRtuw] – Create a minidump (default) 
  /o – Overwrite any existing file 
  /u – Append unique identifier to dump name

“.dump /ma” is the recommend method of creating a complete memory dump of a user mode process.

So, to create a complete memory dump of the SQL Server to c:\temp, execute the following:

.dump /ma c:\temp\sqldump.dmp

Method 3 (From within SQL Server)

From inside SQL Server, you can create a dump using two different methods.  First, to create a manual dump immediately, use the following undocumented command:

DBCC STACKDUMP

This will create a memory dump in the LOG directory of your SQL Server instance installation.  To enable this method to create a FULL DUMP, you must turn on trace flags 2544 and 2546:

dbcc traceon(2544, -1) 
go

dbcc traceon(2546, -1) 
go

dbcc stackdump

To create only a minidump, enable trace flag 2546.  To create a full-filtered dump, use trace flag 2551.

You can use the undocumented DBCC DUMPTRIGGER command to enable SQL Server to create a dump on the occurrence of an error.  You can use the following to enable a full dump on error 802 (There is insufficient memory available in the buffer pool):

— turn on TFs for full dump 
dbcc traceon(2544, -1) 
go 
dbcc traceon(2546, -1) 
go

— set DUMP TRIGGER for exception 802 
dbcc dumptrigger(‘set’, 802) 
go

— view exceptions set for DUMP TRIGGER 
dbcc traceon(3604, -1) 
go 
dbcc dumptrigger(‘display’) 
go 
dbcc traceoff(3604, -1) 
go

— Turn off dumptrigger for exception 802 
dbcc dumptrigger(‘clear’, 802) 
go

Finally, you can also use the –y parameter on SQL Server startup to achieve the same functionality as SQL Server’s DBCC DUMPTRIGGER.   For more information refer to:

http://blogs.msdn.com/psssql/archive/2008/01/10/how-it-works-sql-server-engine-error-messages.aspx

One method not covered in this post is to create the dump from within Task Manager as seen here:

I am not a big fan of this method since you have little control over it.  It will create a full dump inside your user profile by default.   It is also only available on Windows 2008 and Windows 2008 R2 (or Vista and Windows 7).  However, it is yet another way to dump the SQL Server process.

– Jay

How can I create a dump of SQL Server?的更多相关文章

  1. VITAM POST MORTEM – ANALYZING DEADLOCKED SCHEDULERS MINI DUMP FROM SQL SERVER

    https://gennadny.wordpress.com/2014/11/ Since SQL Server 7.0, SQL Server has its own scheduling mech ...

  2. Microsoft SQL Server Version List [sqlserver 7.0-------sql server 2016]

    http://sqlserverbuilds.blogspot.jp/   What version of SQL Server do I have? This unofficial build ch ...

  3. Microsoft SQL Server Version List(SQL Server 版本)

    原帖地址 What version of SQL Server do I have? This unofficial build chart lists all of the known Servic ...

  4. 【转】sql server开启全文索引方法

    利用系统存储过程创建全文索引的具体步骤: 1) 启动数据库的全文处理功能 (sp_fulltext_database) 2) 建立全文目录 (sp_fulltext_catalog) 3) 在全文目录 ...

  5. [SQL in Azure] Provisioning a SQL Server Virtual Machine on Azure

    http://azure.microsoft.com/en-us/documentation/articles/virtual-machines-provision-sql-server/ Provi ...

  6. [SQL in Azure] Getting Started with SQL Server in Azure Virtual Machines

    This topic provides guidelines on how to sign up for SQL Server on a Azure virtual machine and how t ...

  7. Server-side Query interception with MS SQL Server

      up vote15down votefavorite 5 I'm researching into intercepting queries that arrive at the SQL Serv ...

  8. SQL Server事务详解

    事务定义: 事务是单个的工作单元.如果某一事务成功,则在该事务中进行的所有数据更改均会提交,成为数据库中的永久组成部分.如果事务遇到错误且必须取消或回滚,则所有数据更改均被清除. 事务三种运行模式:  ...

  9. Create XML Files Out Of SQL Server With SSIS And FOR XML Syntax

    So you want to spit out some XML from SQL Server into a file, how can you do that? There are a coupl ...

随机推荐

  1. mysql导入数据库出现:Incorrect string value: '\xE7\x82\xB9\xE9\x92\x9F' for column 'chinese' at row 1

    mysql导入数据库出现:Incorrect string value: '\xE7\x82\xB9\xE9\x92\x9F' for column 'chinese' at row 1 使用 sho ...

  2. 【转】cve2014-3153 漏洞之详细分析与利用

    背景学习: Linux Futex的设计与实现 使用者角度看bionic pthread_mutex和linux futex实现 By kernux TopSec α-lab 一 漏洞概述 这个漏洞是 ...

  3. 运行HelloWorld.class是报错(错误: 找不到或无法加载主类 HelloWorld.class)

    1.从毕业到现在工作了几个月了,每天都是在写一些js代码,感觉作为一个web程序员,java还是十分重要的,于是自己买了一本java书来边学边练习,然后发现自己连使用记事本来编写的HelloWorld ...

  4. Selenium2+python自动化36-判断元素存在【转载】

    前言 最近有很多小伙伴在问如何判断一个元素是否存在,这个方法在selenium里面是没有的,需要自己写咯. 元素不存在的话,操作元素会报错,或者元素有多个,不唯一的时候也会报错.本篇介绍两种判断元素存 ...

  5. k8s的存储Volume

    1.Volume简介 我们经常会说:容器和 Pod 是短暂的.其含义是它们的生命周期可能很短,会被频繁地销毁和创建.容器销毁时,保存在容器内部文件系统中的数据都会被清除. 为了持久化保存容器的数据,可 ...

  6. hdu 5187(高精度快速幂)

    zhx's contest Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Tot ...

  7. Ajax 生成流文件下载(实现代码)

    // 绑定导出按钮    $("#btnExport").clickCheckLogin(function () { var form = $("<form> ...

  8. jQuery 立即执行

    ;(function($){// 可以去掉开头的 ; (分号),国外的开发人员编写的插件时的一种习惯 $.fn.pluginName = function() { // Our plugin impl ...

  9. 使用Redis实现高并发分布式序列号生成服务

    序列号的构成 为建立良好的数据治理方案,作数据掌握.分析.统计.商业智能等用途,业务数据的编码制定通常都会遵循一定的规则,一般来讲,都会有自己的编码规则和自增序列构成.比如我们常见的身份证号.银行卡号 ...

  10. (十五)mysql中间件MyCAT实现

    1)拓扑如下和实现目标 写操作:都在master 读操作:在slave1上 当master1挂了,写操作自动切换到master2上 当master2挂了,写操作自动切换到master1上 2)Myca ...