Using DATEADD, DATEDIFF and DATEPART T-SQL Functions in Simple Terms

Using DATEADD, DATEDIFF and DATEPART T-SQL Functions in Simple Terms
Rate this post

This article focuses on developing a basic understanding of how to use one of the most common Transact-SQL date functions: DATEADD, DATEDIFF, and DATEPART.

In this article, I also stressed the importance of properly using these date functions in daily date manipulations followed by some interesting scenarios in which these date functions can be used in a collaborative way to solve slightly complex date calculations.

Since these functions are primarily used in date manipulations, let us first try to understand what we mean by date manipulation.

Read More

MERGE: Updating Source and Target Tables Located on Separate Servers

MERGE: Updating Source and Target Tables Located on Separate Servers
4 (80%) 2 votes

What is the MERGE statement?

Using the MERGE statement, we can change data in a target table based on data in a source table. Using it, we can execute INSERT, UPDATE and DELETE on the target tables within a single query block. It joins both tables using columns, common in both tables like the primary key. Based on how column data matches, changes apply to data of target table. The following image illustrates how “MERGE” works:

Read More

Overview of Data Compression in SQL Server

Overview of Data Compression in SQL Server
3 (60%) 1 vote

The database is a critical and vital part of any business or organization.  The growing trends predict that 82% of enterprises expect the number of databases to increase over the next 12 months. A major challenge of every DBA is to discover how to tackle massive data growth, and this is going to be a most important goal. How can you increase database performance, lower costs, and eliminate downtime to give your users the best experience possible? Is data compression is an option? Let’s get started and see how some of the existing features can be useful to handle such situations.

In this article, we are going to learn how the data compression solution can help us optimize the data management solution. In this guide, we’ll cover the following topics:

  • An overview of compression
  • Benefits of compression
  • An outline about data is compression techniques
  • Discussion of various types of data compression
  • Facts about data compression
  • Implementation considerations
  • and more…

Read More

Navigating SQL Server Error Logs

Navigating SQL Server Error Logs
3.9 (77.14%) 7 votes

Introduction

One of the key skills you need as a database administrator or an IT person is generally the ability to monitor systems very carefully. Lack of this key skill can lead to misdiagnosis when troubleshooting issues. SQL Server exposes a number of tools that can aid the DBA in troubleshooting problems that occur in production. The SQL Server Error Log and the SQL Server Agent Log are two of the most important facilities for troubleshooting SQL Server. In this article, we shall explore the ways we can manipulate the Server and Agent logs.

Read More

Monitoring Backups Across Instances

Monitoring Backups Across Instances
3.3 (65.71%) 7 votes

Introduction

In the last two or three months, I have been asked twice for a solution native to SQL Server that consolidates a backup report for several SQL Server instances across an enterprise. This question came from friends that did not necessarily want to spend money buying a tool but were more inclined to leverage the capabilities of SQL Server. I have thought about two possible ways to achieve this:

  1. Using Linked Servers, catalog views, SQL Agent Jobs and Database Mail
  2. Using Central Management Server

In this article, I will demonstrate the first and hope we shall have a second part of the article sometime later. Read More

Tracking Database Changes Using Working Folder Source Control

Tracking Database Changes Using Working Folder Source Control
4.7 (93.33%) 6 votes

This article talks about a new method to version control a database using a working folder so that historical changes made to the database can be traced back.

Overview

Since this article is based on the new approach to source control a database by overcoming the working folder limitation, it is better to get some basic understanding of the working folder and related things.

Read More

Move Datafiles in SQL Server – Part 2

Move Datafiles in SQL Server – Part 2
3.7 (73.33%) 9 votes

Introduction

In the first part of the two-part series, we explored migrating databases by first updating the master database system catalogs which contain records of the physical location of data files. In the current article, we shall look at two other methods of migrating databases in SQL Server which essentially have the same effect through the approach is different. Read More

How to create Snapshot Replication

How to create Snapshot Replication
3.1 (62.86%) 7 votes

The concept of snapshot replication is simple. It generates and distributes the snapshot of schema and data of articles, appeared at a specific time and updates the changes on subscriptions. When we create snapshot replication, SQL Server creates a Snapshot Agent Job which generates a snapshot of publication database objects. Snapshot is stored on either network location or on the hard drive. You can define the interval to generate the snapshot using the SQL Job schedule. Read More

How to create Transactional Replication

How to create Transactional Replication
3.3 (66.67%) 6 votes

In this article, I am going to demonstrate how to create transactional replication.

Transactional replication generated a snapshot of publication DB objects and data within it. After the snapshot is generated, all the data changes and schema changes occurred on the publisher database are delivered to subscriber databases. In transactional replication, data and schema changes are almost real-time, hence transactional replication can be used to offloading reports and sometimes can be used as DR Site.

Read More

Importance of transaction log in SQL Server

Importance of transaction log in SQL Server
4 (80%) 5 votes

Transaction logs are a vital and important component of database architecture. In this article, we’ll discuss SQL Server transaction logs, importance, and their role in the database migration.

Introduction

Let’s talk about different options for taking SQL Server backups. SQL Server supports three different types of Backups.
1. Full
2. Differential
3. Transaction-log

Before jumping into transaction-log concepts, let’s discuss other basic backup types in SQL Server. Read More