SQL Server tricky Interview Queries

More often, you may find many interviewers ask you tricky SQL interview queries. Be prepared for this kind of MS SQL queries.

Below are few list that I prepared what I experienced in my day-to-day life.

Run above SQL script and see answers. Few of them surely will blow your mind. You may probably think there is bug in MS SQL.!!

Below is answer of all SQL queries.

Be prepared for this kind of queries for that interviewer may ask.!

I will update this post to add more this kind of interesting queries. You can comment below if you know this kind of SQL server tricky queries.

UPDATE:

Cursor in SQL Server

ursor-example-in-SQL-server Cursor in SQL Server is a control structure which process data row by row. It enables rows in a result to process sequentially. SQL Cursor is a type of iterator which can be used to process any record of table & can modify records according to our needs. To use cursors in SQL procedures, you […] Continue Reading →

How to Delete Duplicate Rows in SQL Server

User-Table-with-sample-data In earlier post, I published article about Find duplicate rows in SQL. Now It’s easy when you have small amount of duplicate data. But in million records,it’s very difficult to delete duplicate rows in SQL. Continue with older post, I have added one more duplicate Email.My table will look like below.! Now what I want is, […] Continue Reading →

SQL Order by string And Number

order-by-string-and-number Order By clause is used to order a number or string of any column of SQL. We can esaily order any column if it;s data-type is INTEGER.Suppose we have column contain data like 2A,1,4,3B,11,111 in VARCHAR column and need to order this column.So below SQL tutorial is about Order by String and number in SQL […] Continue Reading →

How to block IP Address from website

block-IP-address Many times we want to block IP Address so particular machine is not able to access website/blog again. People may be hackers,enemies,Invalid clickers or may be another.Below is guide to block IP address from website. Login to Cpanel Account Almost all Hosting providers offers you cPanel.Login to your cPanel,for my example I use BlueHost here. Go to […] Continue Reading →

Date Functions in SQL Server with Examples

Date-functions-in-SQL-server As a good programmer,you need to use many Date functions in SQL Server.I share here most used Date functions of SQL Server which will do different functionality according to its needs. GETDATE() You can easily retrieve current Date Time in SQL Server using GETDATE() function. Query : select GETDATE() CONVERT() Many times,We want to convert Date Format […] Continue Reading →

How to write- create Stored Procedure in SQL Server

A stored procedure is a group of Transact-SQL statements compiled into a single execution plan.(Source: MSDN).To create stored procedure in SQL Server,Go to Database ->Programmability->Stored Procedures.Click right click and click on New Stored Procedure.It will create a new Query Window for you. You will get above image script in your SQL Server.In this script,you have to […] Continue Reading →