SQL Clone
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in

Si vis pacem, para sql

Developer, Administrator and Architect with 10+ years of expertise in data analysis, design, programming, performance tuning, upgrades, migrations, high availability solutions implementation, backup & recovery strategies and database capacity planning expertise.

Useful T-SQL queries and scripts to work in SQL Server

This post is about some queries and scripts that I use in my daily work on SQL Server. Some of them are self-explanatory, i.e. the name of the query/script already describes its purpose. However, if you need to get some more details around, then you may need to add some… Read more

1 comments, 4,253 reads

Posted in Si vis pacem, para sql on 5 December 2018

How to Write a Better T-SQL Code

Here are some basic guidelines that are good to consider when writing T-SQL (Transact SQL). These tips and hints are aimed for the beginner-level T-SQL developers.

Always Use a Schema for the Programmable Objects

For example, instead of writing BillOfMaterial you should have dbo.BillOfMaterial in a query.
Having SELECT… Read more

4 comments, 4,260 reads

Posted in Si vis pacem, para sql on 16 November 2018

Some New Cool Features in SSMS

SSMS new versions come up with some cool features. The new features provide support for the SQL Server 2008 databases and onward.

Vulnerability Assessment (active from SSMS 17.4)

Right click on a database Tasks -> Vulnerability Assessment -> Scan For Vulnerabilities… will make a scan of your database for possible… Read more

0 comments, 832 reads

Posted in Si vis pacem, para sql on 28 December 2017

Using Time Zones in SQL Server

The usage of time zones in applications becomes inevitable, especially with the globalization of the applications. Reports need to be run in different time zones. Services have to consider the time zones. Applications’ users nowadays, which are around the globe use their local zones and etc.

The programming on database… Read more

2 comments, 1,880 reads

Posted in Si vis pacem, para sql on 18 August 2017

RegEx in SQL Server for replacing text

In this post, I’m presenting usage of two functions that use Regex. My previous post was about searching text in SQL Server using regex, and now I’m showing how to use it for replacing text in SQL Server.

The two new functions added to the SqlRegex.dll are RgxTrim() and… Read more

0 comments, 11,451 reads

Posted in Si vis pacem, para sql on 1 August 2017

RegEx in SQL Server for searching text

As a database developer or DBA, or even software developer, you must have met up with the difficulties of finding some strings/sub-strings in the text columns. In such situations, we usually make two or more queries in order to cover the various cases, or even don’t try it because it’s… Read more

1 comments, 683 reads

Posted in Si vis pacem, para sql on 24 July 2017

Microsoft Certified Trainer!

For the first time in my career, I’m a Microsoft Certified Trainer (MCT). This title came as a result of my two-year working as a trainer at the Seavus Educational and Development Center (SEDC), so I’m very thankful to SEDC.

I teach several subjects related to SQL Server… Read more

0 comments, 411 reads

Posted in Si vis pacem, para sql on 28 May 2017

Some stuff with Date and Time in SQL Server

I’m writing this post because I want to put some more stuff around dates and times in one place. I additionally teach SQL Server classes and often come up to talk about dates and times, and converting them to string representations. Of course I don’t always have time enough to… Read more

0 comments, 803 reads

Posted in Si vis pacem, para sql on 9 May 2017

Multiple usage of functions to ensure “value” is not null? – NO

In this post I’m describing a piece of code that is not well written. The author (unknown) had applied three functions for a variable to ensure it never accepts NULLs. The code is given in the next screen shot.

ScreenShot 1. The query with three functions on OriginalAmount

As you… Read more

7 comments, 2,337 reads

Posted in Si vis pacem, para sql on 29 April 2017

Mixed page allocation

MIXED_PAGE_ALLOCATION is a new option introduced with SQL Server 2016. It controls whether the database can create initial pages using a mixed extent for the first eight pages of a table or index. There is a bit column in the sys.databases view with values:

  • OFF -The database always creates initial pages…

Read more

0 comments, 1,275 reads

Posted in Si vis pacem, para sql on 8 April 2017

A rare Reporting services issue

This post is about a reporting services configuration issue that you will face after changing the database server name. I’ve blogged about Changing SQL Server name and warned on issues with SSRS.

After making a change of the server name, a period later when I run my Report manager I was… Read more

0 comments, 246 reads

Posted in Si vis pacem, para sql on 10 March 2017

INPUT and OUTPUT type parameters in stored procedures

Output-only parameters do not exist in the T-SQL procedures. They are all either input-only or input/output.

The OUTPUT keyword in the procedure’s definition or its invocation, designates the input/output type of a parameter.

The shorten CREATE syntax for stored procedure is the following

CREATE { PROC | PROCEDURE }   procedure_name Read more

1 comments, 298 reads

Posted in Si vis pacem, para sql on 7 March 2017

Database cloning – CLONEDATABASE

Database cloning is a new feature supported in SQL Server. Only SQL Server 2014 SP2 and SQL Server 2016 SP1 support cloning.

The command syntax is very simple

DBCC CLONEDATABASE (source_database_name, target_database_name)

For example the next command

DBCC CLONEDATABASE (AdventureWorks2014, AdventureWorks2014_Clone)

will create database AdventureWorks2014_Clone with files created in the… Read more

0 comments, 664 reads

Posted in Si vis pacem, para sql on 27 February 2017

SQL and the other technologies

I was curious about how the SQL language stands with the other technologies. Next table shows it. The data is taken from StackOverflow.

2013 2014 2015 2016
JavaScript 56.6% 58.9% 54.4% 85.3%
SQL 59.6% 57.1% 48.0% 58.9%
C# 44.7% 37.6% 31.6% 35.3%
Java 42.5% 37.6% 31.6% 35.3%
PHP 34.8%…
Read more

0 comments, 509 reads

Posted in Si vis pacem, para sql on 31 January 2017


I’ve seen quite a lot of usage of both functions in the T-SQL codes. However, their usage sometimes matters. The expectation from @@IDENTITY can sometimes not be the desired.

This post shows why you should use SCOPE_IDENTITY() instead of @@IDENTITY when using it with tables that have triggers.


Read more

0 comments, 200 reads

Posted in Si vis pacem, para sql on 27 January 2017

My first Microsoft MVP Award!

Exactly 10 years ago I started my career as a Software developer in a Bank, which for me meant directing my career in the fields of data analysis, processing and data architecture. Fortunately all my next jobs were/are strongly related with data, and today I’m a proud and dedicated database… Read more

0 comments, 165 reads

Posted in Si vis pacem, para sql on 10 January 2017

Indexes optimize for the system databases

Maintenance of the system databases in SQL Server regarding the indexes is important. The system tables also have indexes and their maintenance is of asset on the busy environments.

It’s also important to know that the indexes in msdb and master are marked as system objects, so if you have… Read more

0 comments, 227 reads

Posted in Si vis pacem, para sql on 23 December 2016

SQL Server and Hyper-threading

This post is about the CPU utilisation in the Standard, Web and Express editions of SQL Server because there is limitation for them. Licensing is given at the end of this post.

Physical environments

According to the official msdn references ([1], [2], [3]), Table… Read more

0 comments, 251 reads

Posted in Si vis pacem, para sql on 20 December 2016

CPU Spikes Caused by Periodic Scheduled Jobs

In this article I’ll show you how to eliminate periodic spikes in the CPU that are caused by the jobs that execute periodically. Figure 1 shows such a situation. You can see the spikes occurring every minute.

Figure 1. CPU spikes caused by periodic-scheduled jobs

There is a good reason… Read more

0 comments, 243 reads

Posted in Si vis pacem, para sql on 1 December 2016

What does an Index mean to a Query

This post is about the importance of a right index to a query. The following simple query was considered.

    [GroupBy1].[A1] AS [C1]
        MAX([Extent1].[CreatedDate]) AS [A1]
        FROM [dbo].[GeoIP2Location] AS [Extent1] WITH (NOLOCK)
    )  AS [GroupBy1]

Even simple, this query was causing troubles on our production systems. The query… Read more

0 comments, 232 reads

Posted in Si vis pacem, para sql on 11 November 2016

Older posts