Dbrestorer is a simple utility for restoring SQLServer database from the backup file.

In compare to SQLServer Mangement Studio, DbRestorer is much easier to use because basically all you need is just to drag the backup file in to the window; Moreover, it also provides the ability to customise the database name and the path to where you want to relocate the mdf and ldf files.

Read More »

Chain Multiple Converters


This article describes how to chain multiple WPF value converters into a set, like most command-line environments that allow the output of one command to be piped into another command as input. It enables and encourages us write reusable converters and combine them to gain a new powerful converter, rather than write all the conversion code in one single converter.

Let say we need to converter false to Visible, true to Collapse. Of course we can write a new FalseToVisibleConverter to get the job done, but following this style could result in a huge number of specific non-reusable converters as we may have lots of combinations. The better way is to combine/pipe/reuse the InverseBoolConverter (A wildly used custom converter to inverse true to false and vice versa) and the existing BooleanToVisibilityConverter (Provided by WPF, which can convert true to Visible and false to Collapse).

Read More »

Dump Analysis via WinDbg


In computing, a core dump (in Unix parlance), memory dump, or system dump consists of the recorded state of the working memory of a computer program at a specific time, generally when the program has terminated abnormally (crashed). In practice, other key pieces of program state are usually dumped at the same time, including the processor registers, which may include the program counter and stack pointer, memory management information, and other processor and operating system flags and information. Core dumps are often used to assist in diagnosing and debugging errors in computer programs. – from Wikipedia’s Core Dump page.

This article figures out the steps to investigate a dump file for exception information and stack trace via WinDbg.

Read More »

EditorTemplate with Customizable HTML Attributes


When using EditorTemplate, we wouldn’t set some attributes (e.g. the Bootstrap grid width col-md-* ) of the widget in the template, so they can be customized via the second parameter of HtmlHelper.EditorFor for different contexts/pages. On the other hand, to avoid duplication, it’s the widget’s responsibility to set the attributes that the widget always has or belong to the widget rather than its container.

This article illustrates how to pass the HTML attributes to the EditorTemplate and merge with the attributes reside in the EditorTemplate itself.

Read More »

Get Recent SQLServer Queries from the Server Side via DMV


This article discusses how to get the recent queries as well as the last or current running query for a specific SPID.

Get Recent Queries from the Query Cache

The idea is to find the sql_handle for the recently executed queries from the dm_exec_query_stats table and then find the underlying SQL text from the dm_exec_sql_text table for the sql_handles. Below shows the query to achieve the goal:

SELECT  sql_text.text, last_execution_time, creation_time
FROM    sys.dm_exec_query_stats AS stats
        CROSS APPLY sys.dm_exec_sql_text(stats.sql_handle) AS sql_text
order by last_execution_time DESC

Read More »