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

Rename table in MS SQL Server

Rename table in MS SQL Server: sp_rename 'old table name', 'new table name'   Read more»

SQL and databases

How to resolve Microsoft SQL Server Error 15023 “User already exists”

Microsoft SQL Server Error 15023

When you restore a database from backup to your SQL server in test environment, you will try to add Role to a restored database for user. At this time you may get the error message: An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo). User, group or role ‘UserName’ already exists in the […] Read more»

SQL and databases

How to select all duplicates from Transact-SQL table on namesakes example

It’s a little tutorial about how to get all duplicate records on namesakes example from your database table. For example, we have a table with columns Id, FullName, Birthdate and Phone. Using ‘GROUP BY’ and ‘HAVING’ we can select all namesakes.  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

Transact-SQL string functions

This post is about which string functions there are in Transact-SQL. They allow to modify data you have, make custom queries to select records from database tables. To know them is very important for any developer – using string functions is very good way to decrease load from application server without adding it to SQL because […] Read more»

SQL and databases

CASE conditions in Transact-SQL

Another way for using conditions in Transact-SQL besides IF…ELSE is CASE operator. The syntax is some different from IF…ELSE but in some cases more readable. CASE also uses the word “THEN”. Read more»

SQL and databases

Differences between MS SQL Server 2012 Express

On Microsoft.com you can download Microsoft® SQL Server® 2012 Express. It’s a free software for home use – education, tests or something like this. When you click “Download” link on a page  http://www.microsoft.com/en-US/download/details.aspx?id=29062, you can see a list of versions for downloading. Which one to choose? Read more»

SQL and databases

Popular Posts