Saeid Hasani is a Senior Database Developer, SQL Server Consultant, freelance SQL author, T-SQL Trainer and MSDN SQL Server Forums Moderator. His main expertise is T-SQL Programming and Query Tuning. As a database developer, he has several years of experience in developing software in various domains such as MIS, ERP and customized enterprise applications. As a freelance SQL author, he has been writing about SQL since 2010.

Table of Contents

Note: This is a "User Page" (click for a list of all user pages on TechNet Wiki). User pages on TechNet Wiki exist for the following reasons: (1) To link to these pages from various online profiles, blog posts, etc. (2) To allow collaboration on filling out such information. (3) To allow easy editing for filling out such information. (4) To act as an aggregation or collection of links that help define what a person does.

Blog

Saeid's blog, sqldevelop, centers around T-SQL and technologies on Microsoft SQL Server:

     https://sqldevelop.wordpress.com/

 

TechNet Wiki

All Saeid's Wiki articles he authored or co-authored: 

     http://social.technet.microsoft.com/wiki/contents/articles/tags/Saeid+Hasani/default.aspx

Saeid's Profile:

     https://social.technet.microsoft.com/Profile/saeid%20hasani

SQL Articles (TechNet Wiki)

This section gathers all articles that he has written about T-SQL and Microsoft SQL Server published on TechNet Wiki.

Summary List (ORDER BY PublishDate DESC)

1.        T-SQL: Improve the Performance for LIKE Wildcard by Changing the Collation

Contributed article to Microsoft TechNet Guru Competition – June 2015

2.        T-SQL: Make a Read Copy of Database by Using Synonym, Trigger and SQL Agent Job

Winner of Silver Medal in Microsoft TechNet Guru Competition – May 2015

3.        T-SQL: Check Database Consistency Using Visual Studio SSDT

Winner of Gold Medal in Microsoft TechNet Guru Competition – April 2015

4.        T-SQL: Table Variable vs Temp Table (Two Reasons for Using Table Variable Instead of Temp Table)

Winner of Silver Medal in Microsoft TechNet Guru Competition – April 2015

5.        T-SQL: How to Sort a Column that Contains Character-Separated Numbers

Winner of Gold Medal in Microsoft TechNet Guru Competition – March 2015

6.        T-SQL: Troubleshooting When a Column Alias Created in the SELECT Clause Cannot be Used in the ORDER BY Clause

Winner of Silver Medal in Microsoft TechNet Guru Competition – March 2015

7.        T-SQL: How the Order of Elements in the ORDER BY Clause Implemented in the Output Result

Winner of Gold Medal in Microsoft TechNet Guru Competition – February 2015

8.        T-SQL: Delete All Rows From a Table Except Top(N) Rows

Winner of Gold Medal in Microsoft TechNet Guru Competition – January 2015

9.        T-SQL: Error Handling for CHECK Constraints

Winner of Silver Medal in Microsoft TechNet Guru Competition – December 2014

10.    T-SQL: Negative Effects of SSMS Query Designer

Winner of Bronze Medal in Microsoft TechNet Guru Competition – December 2014

11.    T-SQL: CHECK Constraints

Winner of Bronze Medal in Microsoft TechNet Guru Competition – November 2014

12.    Calling Stored Procedures Using Transact-SQL

Winner of Bronze Medal in Microsoft TechNet Guru Competition – September 2014

13.    T-SQL: How to Generate Random Passwords

Winner of Gold Medal in Microsoft TechNet Guru Competition – June 2014

14.    T-SQL: PIVOT Ordered pair Columns

Contributed article to Microsoft TechNet Guru Competition – January 2014

15.    Error Handling within Triggers using T-SQL

Winner of Bronze Medal in Microsoft TechNet Guru Competition – December 2013

16.    T-SQL: Simplified CASE expression

Winner of Bronze Medal in Microsoft TechNet Guru Competition – November 2013

17.    All-at-Once Operations in T-SQL

Winner of Bronze Medal in Microsoft TechNet Guru Competition – October 2013

18.    Structured Error Handling Mechanism in SQL SERVER 2012

Winner of Gold Medal in Microsoft TechNet Guru Competition – September 2013

19.    Sort Letters in a Phrase using T-SQL 

Winner of Gold Medal in Microsoft TechNet Guru Competition – August 2013

20.    Custom Sort in Acyclic Digraph

Winner of Bronze Medal in Microsoft TechNet Guru Competition – August 2013


Detailed List (ORDER BY PublishDate DESC)

Publish date: 01-03-2015 10:19 PM

Summary:

This article is the outcome of an MSDN forum question. The problem is how to delete all rows from a table except the Top (N) rows, for example, leaving only the top (1000) rows. All Code samples in this article are downloadable from this  link...

Winner of Gold Medal in Microsoft TechNet Guru Competition - January 2015


Publish date: 12-31-2014 9:24 PM

Summary:

In the former article about CHECK constraints, we did not cover how to handle the errors when a CHECK constraint violates. In this article, we cover this important topic. It has worth to take a look at that article, if it needed. All Code samples in this article are downloadable from this link...

Winner of Silver Medal in Microsoft TechNet Guru Competition - December 2014


Publish date: 12-29-2014 4:59 PM

Summary:

Microsoft Query Designer is a visual tool which exists in SQL Server Management Studio (SSMS) that make it easy to write T-SQL queries. It is visual and handy. But using this tool has its negative effects. In this short writing we see some of this effects...

Winner of Bronze Medal in Microsoft TechNet Guru Competition - December 2014


Publish date: 11-29-2014 10:34 PM

Summary:

Constraints are database objects for providing Data Integrity. They are rules which apply to restrict values in a table. CHECK is just a constraint type. It can limit the values that are inserted or updated in a table column. We can use check constraints to validate data or define custom scope of values such as some foods, birds etc. They can be very handy when designing a database. We will be more familiar with them in this article. This article has two parts. The first part is Design and Implementation and focuses on how to create CHECK constraints. The second part is CHECK Constraints in Action in which we will focus more on the details of the CHECK constraint implementation using T-SQL language.

Winner of Bronze Medal in Microsoft TechNet Guru Competition - November 2014


Publish date: 09-30-2014 11:39 PM

Summary:

The complex part after writing a stored procedure is how to call it. In many cases, caller of the stored procedure is not a person who wrote it. She/he may not have full permission to see stored procedure definition while she/he can call it. So, we need to have a clear protocol to call stored procedures that works fine in all conditions. To achieve this, we will see how to pass parameter to a stored procedure. There are lots of questions related to the calling stored procedures like this question in Transact-SQL MSDN Forum which could be a good reason for writing this article.

Winner of Bronze Medal in Microsoft TechNet Guru Competition - September 2014


Publish date: 06-29-2014 12:15 AM

Summary:

This article shows how to write an SQL Server Scalar Function which generates a random password. To avoid copy/paste each code block, all code blocks that used in this article is available for download from TechNet Gallery.

Winner of Gold Medal in Microsoft TechNet Guru Competition - June 2014


Publish date: 01-31-2014 7:44 PM

Summary:

In mathematics, an ordered pair (a, b) is a pair of mathematical objects. The order in which the objects appear in the pair is significant: the ordered pair (a, b) is different from the ordered pair (b, a) unless a = b. Ordered pairs are also called 2-tuples. We can also use this mathematical concept in the design of our databases. We can use two columns, for example, in accounting transaction tables to know what Entity (s) called what accounting transaction.

Contributed article to Microsoft TechNet Guru Competition - January 2014


Publish date: 12-29-2013 9:16 PM

Summary:

The goal of this article is to provide a simple and easy to use error handling mechanism within triggers context. This article is completely compatible with SQL Server 2012 and 2014.

Winner of Bronze Medal in Microsoft TechNet Guru Competition - December 2013


Publish date: 11-30-2013 10:41 PM

Summary:

The goal of this article is providing explanations about using CASE expression and its alternatives which introduced in SQL Server 2012. This article is completely compatible with SQL Server 2012 and 2014.

Winner of Bronze Medal in Microsoft TechNet Guru Competition - November 2013


Publish date: 11-01-2013 12:00 AM

Summary:

I remember when I read about this concept in a book from Itzik Ben-Gan in 2006, I was so excited and could not sleep until daylight. When I encountered the question about this concept in MSDN Forum, I answered it with the same passion that I read about this mysterious concept. So I made a decision to write an article about it. I want to ask you to be patient and do not see the link of the question until end up reading this article. Please wait, even you know this concept completely, because I hope this will be an amazing trip.

Winner of Bronze Medal in Microsoft TechNet Guru Competition - October 2013


Publish date: 09-30-2013 11:35 PM

Summary:

The goal of this article is to provide a simple and easy to use error handling mechanism with minimum complexity. This article is completely compatible with MS SQL SERVER 2012 and 2014.

Winner of Gold Medal in Microsoft TechNet Guru Competition - September 2013


Publish date: 08-31-2013 9:18 PM

Summary:

This article comes up from this creative question in MSDN forum. The problem is how can we sort the letters in a phrase just using T-SQL? To clarify the question, for instance the desired result for CHICAGO must be ACCGHIO.

Winner of Gold Medal in Microsoft TechNet Guru Competition - August 2013


Publish date: 08-30-2013 12:43 AM

Summary:

This article is derived from this MSDN forum post. This article addresses the task of how to present a Tree in a custom order. In fact, the article title could be pre-order tree traversal.

Winner of Bronze Medal in Microsoft TechNet Guru Competition - August 2013