New Date-Related Functions in SQL Server 2008 and Later

Along with the new data types DATE, TIME and DATETIME2 in SQL Server 2008, new and enhanced functions are also included. New Date Functions Added in SQL Server 2008 and Later The new data functions originally added in SQL Server 2008 are : SYSDATETIME SYSUTCDATETIME SYSDATETIMEOFFSET SWITCHOFFSET TODATETIMEOFFSET A more thorough explanation follows: SYSDATETIME This … Read more…

Where are temporary tables stored in SQL Server?

Many people ask: “Where are temporary tables stored in SQL Server?” and that’s a very good question. There are many cases where we need to create temporary tables in SQL Server and for various reasons. Such reasons may include: Breaking the logic of a large and complex SQL Statement in smaller portions of code. Increase the … Read more…

Manipulating EXCEL Worksheets with the OPENROWSET Command

In this article, we will be discussing about manipulating EXCEL 97-2003 worksheets with the OPENROWSET command. About the OPENROWSET Command SQL Server provides among other the neat feature of the OPENROWSET command. OPENROWSET allows establishing ad hoc connections using OLE DB. It actually allows one-time access to remote data from an OLE DB data source. If … Read more…

Divide by zero error encountered

In this article, we will be discussing about the “Divide by zero error encountered” error message in SQL Server. About the “Divide by zero error encountered” error message Well, as the error message says, whenever we have a division within a SQL query and the denominator has the value of zero (0) we get this … Read more…

String or binary data would be truncated

There are many times where a query may result to the following error: String or binary data would be truncated. The statement has been terminated. We will go through a simple example for explaining this behavior.   Reproducing the “String or binary data would be truncated” error Creating the Sample Table Consider the following table: CREATE TABLE … Read more…

Commonly used string functions in SQL Server

In this article, we provide a list of commonly used string functions in SQL Server. By combining these functions, it is possible to easily manipulate strings. For each function, we provide useful examples, that can help you better understand these functions’ usage.   REPLICATE This function given a string and an integer N, it repeats … Read more…

Getting table index information in SQL Server

At some time today, I had to compare the indices of various database tables. To this end, I needed a fast way of getting index information for specific tables. In SQL Server, there is a system stored procedure (stored in the master database) called sp_helpindex. The syntax for using it is the following: EXEC sp_helpindex … Read more…

Backup Compression in SQL Server

Hi friends, this article discusses the “Backup Compression” feature in SQL Server.   About Backup Compression in SQL Server How many times have we backed up a database and then we have tried to minimize the size of the backup set by compressing it with an archiving utility? I am quite sure that such cases … Read more…

Table-Valued Parameters (TVP) in SQL Server 2008 and Later

In this article, we will be discussing about Table-Valued Parameters (TVPs) in SQL Server 2008 and later. Support of Table-Valued Parameters is another great new feature in SQL Server 2008 and later. I am sure that all of us had to make a stored procedure or function call in SQL Server many times. In the … Read more…