Category Archives: SQL Server

This category contains all SQL related articles

SQL Triggers – An Introduction

By | December 8, 2018

SQL Triggers – An Introduction Contents Introduction Magic Tables Difference between Stored Procedure and Trigger DML Triggers After Triggers Syntax of the After trigger Example of After Trigger for Insert Example of After Trigger for Delete Example of After Trigger for Update Instead of Triggers DDL Triggers DDL Trigger for Create Table DDL Trigger for… Read More »

Difference between Stored Procedure and Trigger

By | November 1, 2018

Difference between Stored Procedure and Trigger     SQL Stored Procedure & SQL Triggers, both are the important objects of SQL. SQL stored procedure are the set of logically group of SQL statements which are a group to perform a specific task. Trigger are also similar to SQL Stored procedure as they can also be a… Read More »

Advantages of SQL Stored Procedure

By | November 1, 2018

SQL Stored procedure are the set of logically group of SQL statement which are grouped to perform a specific task. Stored procedure are better than the inline SQL queries as they help in securing the database from SQL Injection. It also help in increasing the performance of the Database. There are many other Advantages of SQL… Read More »

Advantages & Disadvantages of SQL Trigger

By | November 1, 2018

Advantages & Disadvantages of SQL Trigger Introduction Triggers are database objects which are needed to perform some predefined action for automatic execution whenever users try to do execute data modification commands (INSERT, DELETE and UPDATE) on the specified tables. Triggers are helpful since it can help in maintaining the integrity of the data in database tables… Read More »

SQL Script: – How to find the database restoring history of SQL Server databases

By | March 30, 2018

SQL Script to find database restoring history Sometime we need to find out the history of database restoration to get the answers of following questions: -1) Do we need to restore the database again as there is a possibility that it is restored recently? 2) Which backup file (with location information) is used for database restoration?… Read More »

Two Ways to Restore Database from MDF File in SQL Server

By | July 27, 2017

Ways to Restore Database from MDF File Introduction In todays decade Relational database Management system became the necessity of the organizations whether they are small level or large level. In such context SQL Server is the best and successful RDBMS which provides highly integrated services to manipulate the SQL database over the Server. As we… Read More »

How to Resume Suspended Database Mirroring in SQL Server ?

By | September 3, 2016

Resuming Suspended Database Mirroring in SQL Overview Database mirroring is a feature in SQL Server which is creating and maintaining the redundant copies of the database. The purpose behind database mirroring is continuous data availability and minimizes the loss of the data. Redundancy ensures that there is always a one backup copy of the database… Read More »

SQL Script to find all the triggers defined on a database or on a single table

By | August 14, 2015

SQL Script to find triggers in SQL Database Sometime we need to find all the triggers defined on the database. So in this case, we can use the below SQL Query:-SELECT tbl.name as [Table Name] , trig.name as [Trigger Name] , trig.is_disabled FROM [sys].[triggers] as trig INNER JOIN sys.tables as tbl ON trig.parent_id = tbl.object_idIn… Read More »

Interview question – Is Clustered index on column with duplicate values possible?

By | August 13, 2015

Through this article, we are going to discuss three important interview questions of SQL which are given below:-  1) Can we create clustered index on a column containing duplicate values?  2) Can we create a Primary Key on a table on which a clustered index is already defined? 3) If a clustered index is already defined on a… Read More »

Script to find complete months between two given dates

By | July 10, 2015

Complete months between two given dates Below script will help in finding the complete months within the 2 given dates. In the below script we takes below dates as exampleStartdate =2015-07-05 Enddate =2016-01-06 /**********************Script Start**************************/ IF (object_id(‘tempdb..#month’) is not null) DROP TABLE #month CREATE TABLE #month (id int identity(1,1),MonthStartDate DATETIME,MonthEndDate DATETIME) DECLARE @startdate AS DATETIME… Read More »