Transact-SQL

Get records with empty binary items

There’s a column Photo with type “Image” in MS SQL table (database – MS SQL Server 2008 R2). The task is to get all the records where Photo is empty. Values of empty images is “0x00000000”. Read more»

SQL and databases

Count rows in result of SQL query

To receive quantity of rows of the returned records of SQL query, you should use function @@ROWCOUNT. Function @@ROWCOUNT returns the quantity of rows, which were used in a query. Read more»

SQL and databases

Saving changes is not permitted in MS SQL Management studio

Figure 1. Saving changes is not permitted. The changes you have made require the following table to be dropped and re-created

When you modify columns of a table in MS SQL management studio, you got the message “Saving changes is not permitted. The changes you have made require the following table to be dropped and re-created … ” (Figure 1). The reason of this is re-creating of table. It’s really important for productive environment but not […] Read more»

SQL and databases

Concatenating NULL value columns in T-SQL

Figure 2. Concatenating after changing CONCAT_NULL_YIELDS_NULL to OFF

Concatenating of string columns is not very simple task in T-SQL if you don’t know ANSI standart of it. According to ANSI standart of SQL, concatenating of NULL-value is NULL in the result. It’s not clearly for developer, but it is so. Let’s see some features for work with concatenating NULL-value columns. For example, I […] Read more»

SQL and databases

Conditions IF ELSE in Transact SQL

In this post I will write about SQL conditions. It seems to me that construction “IF … ELSE” you can find in any language. Transact SQL is not exclusion. Let’s see IF … ELSE in action on the sample below. Read more»

SQL and databases

Convert datetime columns in Transact SQL

There are two functions for converting SQL data types from one to another. They are CAST and CONVERT. The second function is the best solution for converting datetime to format you need. Read more»

SQL and databases

Microsoft SQL Server. Copy table from one database to another

There are several ways to make a copy of database table in MS SQL Server. I write down some ways to make a copy of table. Which way to choose is your choice according to table structure, indexes and your wish to make something manually. Read more»

SQL and databases

MSSQL: WHERE LIKE equivalent for DateTime

I don’t often use SQL queries but sometimes I have to. And every time it’s the same – I use search engines to find documentation, especially about work with datetime fields. During these readings I found out at least 3 ways to select records with date I need. Read more»

SQL and databases

Popular Posts