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

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 […]

Continue Reading

Question of the Month (July)

Question of the Month Suppose we have a table emp_plan  which contains 4 columns “Empid” (employeeid), Planid (Projectid), Startdate(Allocation Start date) and Enddate (Allocation Enddate). Its structure is given below:-4  Create table emp_plan (empid nvarchar(200),planid nvarchar(20),startdate datetime, enddate datetime) Also below is the script to enter sample data into the table:- insert into emp_plan(empid,planid,startdate,enddate) select ‘001’,’planA’,’2015-05-15′,’2015-05-30′ […]

Continue Reading

Script to find complete months between two given dates

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 […]

Continue Reading

Script to find the complete weeks within two given dates

Complete weeks within two given dates Sometimes we need to find out the complete weeks within two given dates. Below script will help in finding the complete weeks within 2 given dates. In this script, I have used below dates as exampleStartdate=2015-04-12 Enddate=2015-06-10 SET DATEFORMAT YMD if (object_id(‘tempdb..#weekdays’) is not null) drop table #weekdays Declare […]

Continue Reading

SQLTea – New SQL tutorial app in Google play store

SQLTea – Our new SQL Tutorial App on Google Play Store We are happy to announce our new SQL tutorial app SQLTea  ( Native android app) for SQL learning which includes articles from this blog. This application includes  1) Articles for basic concepts like Normalization, Constrains, Joins, SQL Functions, SQL commands etc and also advance […]

Continue Reading

Answer – Objective Question (How many Null values in an unique constraint can be inserted in SQL Server)

Question:- How many NULL value allowed in a column in which Unique constraint is defined in SQL Server? Options:- a) 1 b) 2 c) More than 1 Answer :- Option a) 1 In SQL Server, we can Insert only one null value in a column where we have defined the Unique Constraint. For Example , suppose […]

Continue Reading

Answer – Objective Question (In which database temporary tables are created in SQL Server)

Question :- In which database temporary tables are created in SQL Server? 1) User database (where temporary table are defined)     2) Master database     3) TempDB (Correct Answer) 4) Model Database 5) None of the above Answer  Thanks to all who attempted this question. 84% people gives the correct answer:-) Correct answer […]

Continue Reading