indiandotnet

Grouping Sets–Good to know feature TIP# 60

  Grouping sets is one of the cool feature came in SQL SERVER 2008. Lets understand here with problem and solution. Problem:-  Suppose , We want  an aggregation result in a query with different groups. Firstly we want aggregated result on first column then combination of First & second column then other column combination. So, …

What is Heap table in SQL Server and How to get all the heap table from a database ? TIP # 54

  Heap table:- A table without cluster index is called Heap table. Now you are thinking why we are talking about this. So as  SQL developer we should aware and In next post I will explain which is related to maintenance how to Rebuild a heap table. Now our next question is how to determine …

A hidden feature sp_MSforeachdb TIP #52

  As we discussed yesterday a hidden feature tip #51 which is sp_MSForeachtable . sp_MsForeachtable is useful to run command on each table of selected database. Now what if we want to run command on each database also ? then in that case we need to take help of sp_MsForeachDB. Sp_MsForEachDB  by the name it …

3 different way to find row count of a table ? TIP #45

  Problem:- Many times you want to know how many rows exists in the particular tables. So let me share 3 different way to know this thing Solution:- Let me share 3 different options Option 1:- You all aware of this term which is Count function SELECT COUNT(1)  As Rows FROM [Person].[Person] Option 2:- Sp_Space …

First_value & Last_Value according to group set is that easy ? tip #44

  Problem:-  Most of the time we require data in which we require first value and last value from different group of rows. Now how easy we can get result this is one of the challenge for us. Solution:- Lets understand this by an example. Suppose you have a sales table in which you maintain …

Interview Question- How conditionally sort the records ? TIP#43

  Problem:- Can we sort records according to particular condition ? Solution:- Most of the time developer faces this challenge of sorting records conditionally. I know  many of us faces this question in interview. Lets understand this by an example. Suppose I have a person table in database and  I want to sort the records …

PARSENAME function TIP#29

As the name suggested PARSENAME is the SQL Server function which provide help in parsing. Lets understand this by an example Suppose , I have an IPAddress variable which I need to parse DECLARE @IPAddress AS VARCHAR(100)SET @IPAddress=’412.312.800.713′ SELECT PARSENAME (@IPAddress,1) The syntax of the parsename is simple PARSENAME(String,stringPartIndex) Only few things which  I have …

How to open SQL Profiler from command prompt–TIP # 23

  To open SQL Profiler (right now I am talking about SQL Server 2012) you need to write Profiler.exe on run command as shown in below figure for earlier version you can use profiler90.exe. You can find various parameters option using Profiler.exe –? command When you run this command you will find below screen. Although …

Performance tips – Check no of logical & Physical reads TIP #18

Sometimes, we need to understand what exactly going on with particular statement, stored procedure why it is slow? To check performance of statement what exactly going on we also interested how many logical reads, physical reads a particular statement taking. To achieve this we need to write SET STATISTICS IO ON For exampleGOSET STATISTICS IO …