Custom Paging

Custom Paging is one of the most efficient ways of improving performance in any application. When we use the paging that comes with in controls like Gridview, DataList, DetailsView, ListView etc... is not very efficient as the complete data gets loaded in the memory and paging takes place there. Custom Paging will help bring only request number of rows from our relational database. [More]

Tags: , , , ,

SQL Server | SQL Tricks

Send HTML Formatted Email Using Database Mail

When using database mail, it may be required to send email that is well formatted. Sometimes, we might want to send formatted data with proper header in the email. Below example describes as how we can send such email with table data in email body. For information on how to set up database mail refer to my earlier post here. [More]

Tags: , , , , ,

SQL Server | SQL Tricks

IsZero Scalar Function

In situations where we want to replace zero with some other value, e.g. if division involves some computation that bring zero as a result, then it will result in divide by zero error. For such scenarios we can have IsZero function to replace zero with some other numeric value.
[More]

Tags: , , ,

Scalar Function | SQL Server | SQL Tricks

Display all the date from start interval to end interval using Recursive CTE

Suppose we have a given starting date and end date and we need to list all the dates and weekday in that interval. [More]

Tags: ,

SQL Server | SQL Tricks | Recursive CTE

UNPIVOT in SQL Server

UNPIVOT in SQL Server is just the opposite of PIVOT. I have written an article on PIVOT which you can refer here. There is another article that is written by me on Converting column header of table to row, the same functionality can be achieved by UNPIVOT. So, let's quickly jump into implementing it. [More]

Tags: , , , ,

SQL Server | SQL Tricks

Scalar Function ISEmpty in SQL Server

When we are working with data exchange from flat files or excel files to our relational tables, sometimes, empty records get inserted instead. Since, in SQL Server null and empty records are different, and if we need to have a scalar function that can be used to replace empty records then it can be done as below. [More]

Tags: , ,

SQL Server | SQL Tricks | Scalar Function

Converting XML document to tabular format in SQL Server

XML has become an easiest mode to exchange and transfer data. There can be a scenario when we have received data in xml format and we want to store in tabular format in one of the table that we have created in SQL Server. Below is how we can go about solving such a problem. [More]

Tags: , , , ,

SQL Server | SQL Tricks | XML

Convert Column Header to Row In SQL Server

We all might have come accross scenarios when it is required to convert a column header of a table to a row. It may be because there is a requirement when we want to generate a report that shows data vertically instead of horizontally if number of columns contained in the table is more than number of rows, or any other reason. [More]

Tags: , , , ,

SQL Server | SQL Tricks

FOR XML EXPLICIT

For XML Explicit is a very complex mode but it allows to present the data in any desirable format we want. It can cause maintenance problem because queries can be very big and any change can be overwhelming. One of the advantages of Explicit mode over others is we can output column values as CDATA. [More]

Tags: , , ,

SQL Server | SQL Tricks | XML

FOR XML Auto

For Auto can provide us better ways to display and present nested data. We will start by looking at some examples with For Auto mode to be clearer. [More]

Tags:

SQL Server | XML