How to store UTF-8 data in SQL Server

Category: IT, MS SQL Server, PHP Tags: , , , , , Comments: 2

Very frequently we need to use the data type UTF-8 to store a data in different languages. As described in the MSDN page the UTF-8 data type is stored in the ‘Samples’ folder in SQL Server (Server\100\Samples\Engine\Programmability\CLR\UTF8String). You just need to activate it.

Equal Action to Identical Databases

Category: IT, Transact-SQL Tags: , , , Comments: 0

If I administer 345 identical databases I can do equal action to all of them (or some of them) easy by selecting the names of the databases, generate dynamic code, execute it and select the result and the errors (is any).

SELECT * or SELECT [Column Name] in IF statement in MS SQL Server

Category: IT, MS SQL Server, Transact-SQL Tags: , , Comments: 1

When we decide how to manipulate the data, we use IF statement verification. For example if we export information about merchant sales, we have two common groups of merchants – these we scan (with serial numbers) and these we don’t scan. For both of them we use two BEGIN… END blocks. To verify the type [...]

Select server logins and their roles in SQL Server

Category: IT, MS SQL Server Tags: , , Comments: 0

To view all the server logins and their roles I use the system view sys.syslogins and CASE to convert 1 to “Yes” and 0 to “No”.

Filegroups and Autogrowth in MS SQL Server

Category: IT, MS SQL Server Tags: , , Comments: 0

Yesterday I was asked about the way a table is stored in several files in a filegroup.

DENSE_RANK() function in MS SQL Server

Category: IT, MS SQL Server, Transact-SQL Tags: , , , Comments: 0

As we can read in Books Online in SQL Server
Ranking functions return a ranking value for each row in a partition. Depending on the function that is used, some rows might receive the same value as other rows. Ranking functions are nondeterministic.
I have created simple example for usage of the Ranking function DENSE_RANK().

The difference between WHERE and HAVING filters in SQL Server

Category: IT, MS SQL Server, Transact-SQL Tags: , Comments: 0

The difference between WHERE and HAVING filters in Transact-SQL queries is that WHERE clause is a filter of all the data, while HAVING filters the GROUP BY data. I’ve prepared a simple example.

MS SQL Server Cursor Example

Category: IT, MS SQL Server Tags: , Comments: 1

The cursors in MS SQL Server are not the best way to manipulate the data, because they need more recourse. If you can escape the usage of cursors, do it. OK, the cursors give us a flexible way of manipulating the information. You can imagine a bundle of information, that we use for move through [...]

Generate filename (Name_Date_Time.txt) for a report with Transact-SQL in Microsoft SQL Server

Category: IT, MS SQL Server Tags: , Comments: 0

My ex-colleague asked me how to insert query result in a variable for generate report in Microsoft SQL Server. After few explanations I noticed that she has decided to use SSIS (SQL Server Integration Services) to automate. She sent me an example in which she uses YEAR(), MONTH() and DAY() functions.

Join Tables in MS SQL – FROM or WHERE clause?

Category: IT, MS SQL Server, MySQL Tags: , , Comments: 0

I was interested of the different SQL “accents”. According to Microsoft SQL Server learning books, we query like this:

SELECT
*

FROM
table1 INNER JOIN table2
ON table1.PK = table2.FK
GO