SQL TIps

How to copy table structure only from a SQL Query ? Tip #69

  Recently , one of my friends shared that some interviewer asked him a question “How to copy table structure only from a  SQL Query?” So, Below is simplest query to copy structure only of a table into another table. SELECT * Into #tmpStudentStructureFROM tblStudentSource WHERE 1= 0 in the above query we want to …

How easy it is to check which statements consuming most of the CPU & RAM–TIP #68

  Problem:-  One of the most important question comes in our mind what is the cause of slow  SQL SERVER. We always struggle with following questions Which is highly CPU consuming query ? Which is highly RAM consuming query ? Who is blocking the transaction ? and many more other performance dragging questions. Believe me …

How to take Transaction Log backup ? TIP# 68

  As we discussed in earlier tips how to take full backup and differential backup now in this tip we will see how to take transaction backup . Before taking transaction backup the first and mandatory condition is that you should have a full backup. Just right click the database and go to backup option …

How to take differential backup ? TIP #67

Friends,We were discussing backup from last few post. Now lets take a look one more feature of backup which is differential backup.Differential backup  is backup after last full backup. Before taking Differential backup  it is a mandatory condition to take full backup.Differential backup can speed up your recovery process or we can say restore process.In …

Oh! I forgot When I took last Database Backup ? How to determine this? TIP # 66

  In last few tips TIP #64 & TIP #65  we get information  how to take backup & How to ensure it can be restore? Now lets me share some more information related to backup. Problem:-   Sometimes , we are interested to know when last backup is taken for particular database ? Solution:  The first …

How to take compressed backup in SQL Server TIP #64

Problem:-  A good maintenance plan always said to take backup but sometimes it is very difficult to take backup of database just because of space constraint.We take backup but we don’t have enough space available.Solutions:  SQL server provided  the best way and gave us solution of compressed backup. Now how to take compressed backup let …

Converting Row to Column use Pivot feature TIP #62

  Problem:  Sometimes we may require to convert row data to column. we require pivot view of data. Solution:  Lets understand this by an example below I am using a table variable which have few columns like  Employee, Amount, Month and year. Lets define and create some sample data here. DECLARE @tblEmployee AS TABLE (Employee        …