Support us .Net Basics C# SQL ASP.NET Aarvi MVC Slides C# Programs Subscribe Download

SQL Server Interview Questions and Answers



Part 1 - How to find nth highest salary in sql | Sildes
Part 2 - SQL query to get organization hierarchy | Slides
Part 3 - How does a recursive CTE work | Slides
Part 4 - Delete duplicate rows in SQL | Slides
Part 5 - SQL query to find employees hired in last n months | Slides
Part 6 - Transform rows into columns in sql server | Slides
Part 7 - SQL query to find rows that contain only numerical data | Slides
Part 8 - SQL Query to find department with highest number of employees | Slides
Part 9 - Difference between inner join and left join | Slides
Part 10 - Join 3 tables in sql server | Slides



Part 11 - Real time example for right join | Slides
Part 12 - Can we join two tables without primary foreign key relation | Slides
Part 13 - Difference between blocking and deadlocking | Slides
Part 14 - Sql query to select all names that start with a given letter without like operator | Slides
Part 15 - SQL script to insert into many to many table | Slides
Part 16 - How and why a sql inner left right full and even cross join returns the same row count

16 comments:

  1. thanks for giving sql interview questions....sir can u upload more interview questions.....it may help to all of us....

    ReplyDelete
  2. Hello sir i have a question that if i have a table called
    tblemployee with Id,Name,Age,Salary as column and Id is
    primary key if i will write select * from tblemployee
    where age=some value that is present in age column and only primary key is there on Id column so here clustered index will work or not if yes then how bcaz index is on Id
    column?????????????

    ReplyDelete
  3. No it will not work as clustered index.

    ReplyDelete
  4. Hello sir thanks for giving interview questions....can u upload about "What is Sql tuning and how to achieve it ?"

    ReplyDelete
  5. Hi Sir,

    I have a question.

    If I have a sequence in where clause , how can I fetch data order by data in where clause and null for non matching data.

    e.g : select * from resources where n_res_id in (4,5,6,2,1)

    Expected result :

    id name
    4 Abc
    5 Asd
    6 null
    2 xyx
    1 null

    ReplyDelete
    Replies
    1. if you are retrieving selected ids from table:
      string str="";
      //use datareader :

      then
      while(dr.Read())
      {
      string id=dr["id"].tostr();
      str+=id+",";
      }
      str=str.Remove(str.Length-1);

      pass this str to your query.







      Delete
  6. Hi Hope you can make a video on how to Distribute an amortization schedule for a loan based on schedule like Monday, Wdnesday Friday (MWF) and Tuesday, Thursday and Saturday (TTHS) payment schedule for a specified number of days or months.

    ReplyDelete
  7. please help in using variables used in stored procedure i m very confused using variables how they hold values .

    ReplyDelete
  8. Hell Sir ,
    I need your help in sql server 2008, will you please send me important topic which always ask in interview regarding SQL Server 2008 for one yr experience.

    ReplyDelete
  9. Hi Sir
    I have a question, Please help with query separed columns multivalue in new columns in the same register. I uses SQL server 2008.


    nombre perfil
    karina 1,2,4,5,10,109
    mark 2,3,45,10,11
    Luna
    Juan 109


    Expected result
    nombre perfil perfil1 perfil2 perfil3 perfil4 perfil5
    karina 1,2,4,5,10,109 1 2 4 5 10
    mark 2,3,45,10,11 2 3 45 10 11
    Luna
    Juan 109 109

    tranks

    ReplyDelete
  10. Hi Sir

    I was asked in a recent interview if we can create multiple indices on a tablet E.g. A clustered index on heap and then create a primary key so we have 2 clustered indices.

    Is it possible? Can you explain it with a demo video like you always do.

    Thank you in advance.

    ReplyDelete
  11. Hi Sir,

    I had one interview question which was asked me twice.
    Design a application with SQL database, where database can be replaced by Oracle with minimum changes. is it possible

    ReplyDelete
  12. Hello Sir,
    In the recent interview, I was asked
    -the storage details of how record is fetched from partitioned table.
    -how to determine the execution cost of join query, what are the different execution plans are being made.

    ReplyDelete
  13. Hi.. Sir
    I have two tables

    Table1
    ID Unit Convertion
    1 P 1
    1 S 10
    1 D 100

    Table2
    ID Value
    1 523

    I want join table1 and table2 then result like this

    Unit Convertion NewValue
    D 100 5 523/100 = 5
    S 10 2 523 - (5 * 100) = 23/10 = 2
    P 1 3 523 - (5 * 100) - (2 * 10) = 3/1 = 3

    ReplyDelete
  14. Hello, I got asked this question and have not figured out out on how can this be solve. We have one table called Flights which consists of Origin and Destination as below

    Origin Destination
    LAX SFO
    SFO LAX
    LAX IAD
    IAD ORD
    ORD SEA
    LAX ORD
    SEA SFO
    SEA ORD

    Now if we look at the first two rows then we see that Origin of first row is same as Destination of second row and Destination of First row is same as Origin for second row

    Origin Destination
    LAX SFO
    SFO LAX

    So now if we see scenarios like this, instead of two rows it should display only once i.e.

    Origin Destination
    LAX SFO

    ReplyDelete
  15. Input data:
    ABC 30
    BAC 20
    BCA 50
    XYZ 100
    YZX 40

    Expected o/p:
    ABC 100
    XYZ 140

    i.e words with same set of characters (interchanged in order) will be considered under same bucket, how this can be done in sql query

    ReplyDelete

It would be great if you can help share these free resources