Category Archives: Useful SQL Scripts

Here you can find articles containing some useful technique or script. For example, automatic optimalization of indexes in the database (rebuild or reorganize), database email settings, various checking scripts, etc.

Don’t miss out from category:

SQL IDENTITY (Auto increment) – Automatic value increase, description

IDENTITY is a property in SQL Server that allows for the automatic numbering of records inserted into a table. It creates an automatic increment with unique values without the need for manual insertion of numbers into the table. This function can be utilized with numeric data types, and its typical use is for identifiers and… Read More »

xp_cmdshell – How to Enable cmdshell in SQL Server?

xp_cmdshell is a very powerful procedure that allows you to execute commands via the command-line (cmd) in SQL Server. With cmdshell, you can perform various operations on a Windows server through the SQL platform, such as copying files, creating, deleting, running bcp for data import and export, and more. However, there are significant security risks… Read More »

SQL Server Agent for SQL Express + How to Guide, Task scheduler

SQL Server Agent is a tool integrated into SQL Server that is primarily used for automating and scheduling tasks. Through SQL Agent, you can create Jobs and schedule individual tasks within those Jobs, such as executing scripts, running SSIS packages, using PowerShell, and much more. However, SQL Server Agent is only available in the Standard… Read More »

SQL Automatic Index fragmentation fix in SQL Server + Script

In the previous article (see Index Fragmentation), I described how to detect index fragmentation using a script that utilizes system tables. According to Microsoft’s recommendations, we should reorganize (REORGANIZE) indexes with fragmentation between 5 – 30% and rebuild (REBUILD) indexes with fragmentation above 30%. We will use the script from the previous article and create… Read More »