$$\newcommand{\eqdef}{\overset{def}{=}}$$

Tahir Hassan's Blog

My Technical Notes

Work Blog

Friday, 22 April 2016

Git Tags are so Simple Summary

Listing Existing Tags

To list all the existing tags, we use `git tag`.

Creating a Tag

To tag the current layout, we use `git tag <tagname>`.

Switching to a Tag

To switch back to an old tag, we can use `git checkout <tagname>`.

Monday, 11 April 2016

SQL Server Index Naming Conventions

Naming Summary

The Index will be named according to the following rule:

Index Prefixes

The following table summarises all the prefixes:

Prefix Type
PKC Primary Key, Clustered
PKNC Primary Key, Non Clustered
NCU Non Clustered, Unique
CU Clustered, Unique
NC Non Clustered (Most Common)

Exceptions to this Convention

The one major exception to this convention is when SQL Server Management Studio automatically names the primary key `PK_<table-name>`. It seems a waste of time changing this each time you create a new table.

References

SQL Server Schema and Data Comparison tools in Visual Studio

Summary

In Visual Studio 2013 and later (2015), you can find the SQL Server Schema and Data comparison tools under `Tools` → `SQL Server`. (`New Data Comparison` and `New Schema Comparison`).

Tuesday, 22 March 2016

SQL Server: Working Example of a CSV bulk Import

CSV File

The CSV file content is the following:

It's encoding, in Notepad++, is `Encode in UTF8`.

SQL Table Creation

The following code creates the `dbo.TestTable` table:

Bulk Inserting the Data

The following script inserts the data:

The `GO` at the end is really a signal for SSMS is superfluous if we execute that block ourselves.

Code Reference HyperLinks in Visual Studio 2015

Summary

All is required is a comment starting with a triple forward slash `///` and a `<see cref="path" />` tag:

Monday, 21 March 2016

Creating and Restoring a Database Snapshot

Creating a Database Snapshot

Create a Snapshot the Simple Way

Given a database `Ψ`, we create a snapshot `Ψ_SS` by using:

Create a Snapshot the Advanced Way

Apparently, there are many files that a database comprises of, therefore they all need to be listed when the snapshot is created. The following database script, by Tom Phillips from MSDN forum, will create the snapshot automatically, taking into account potentially multiple database files:

Viewing the Snapshot

It seems that a snapshot is just a regular database but has been "marked" as a snapshot. Within SSMS, the snapshot can be viewed under Databases → Database Snapshots.

Restoring the Snapshot

Simple Restoration Code

We restore `X_SS` over `X` using this simple code:

Issues when Restoring

When restoring the snapshot, there may be connections to the database we have to kill. StackOverflow - Disconnect active connections has many answers with solutions to this.

Deleting the Snapshot

Deleting a snapshot is just like deleting a regular database:

Re-instating Forms Authentication in MVC 5

Summary of Action

Comment out the following line, found in `<system.webServer>` element: