TRICKY SQL INTERVIEW QUERIES QUESTIONS ANSWERS FOR EXPERIENCED SQL DEVELOPERS

Hey guys, I am writing this post after many days, after many comment by SQL Guys, Every one want to see new post related to SQL Interview q...

Hey guys, I am writing this post after many days, after many comment by SQL Guys, Every one want to see new post related to SQL Interview questions, I have already written many Sql interview queries, In the bunch which are related, So the visitor looking for new queries so in this post, at a time I cant post many but, keep posting new query which I will face.
So for new tricky queries I need you help, If you have any tricky Sql queries then please post as a comment. It will be helpful for other.

So lets discuss new a query, This is not new but little bit tricky.

Query : There are two tables T1 and T2 with two columns, I want to swap the name of both tables, based on ID column. How you will do that.
Tables:


Ans:
--First copy T1 data in to temp table
SELECT * INTO #T1 FROM T1
--Then Update T1 with T2
UPDATE T1 SET T1.NAME = T2.NAME FROM T1 INNER JOIN T2 ON T1.ID = T2.ID

--Then Update T2 With Temp talbe(#T1)
UPDATE T2 SET T2.NAME = #T1.NAME  FROM T2 INNER JOIN #T1 ON T2.ID = #T1.ID

DROP TABLE #T1 --Drop temp table Table

Output after run the above queries.
If you have another solution then please comment.. I will post here..

Related

TECHNICAL 8326832704144852102

Post a comment

  1. Would you please email me the PDF for Set 15, theoretical answers PDF. My email is fatima.s417@gmail.com. Your site is very informative.

    ReplyDelete
  2. Great list of questions! Here's a few more I think you should consider adding to your list too:
    http://cc.davelozinski.com/general/tricky-csharp-and-sql-interview-questions

    _

    ReplyDelete
  3. your article is very nice i like this article and i would like to get from more information about this article please keep sharing this. i am a writer working with phd thesis writing service. thesis writing help to all students. this is very effective one.

    ReplyDelete
  4. hai
    i have t1 and t2 table
    t1 have
    a
    b
    c
    d
    =====
    t2 have
    c
    d
    e
    f

    i want to join two tables .....
    so i want innerjoin, left,right join output....

    ReplyDelete
  5. No need for temp table you can simply do this.

    update t1
    set Name = (select t22.Name from t2 t22 where t1.ID=t22.ID)

    ReplyDelete
  6. When you are being promised round-the-clock Customer Support and life-time replacement then don’t think twice any time you Buy facebook reviews from a provider. buy facebook 5 star text reviews

    ReplyDelete
  7. They are tricky indeed. It was nice to read this article about them. Nice job.

    ReplyDelete
  8. You could also require these USA Facebook Suches as for succeeding competitors that are held online. buy usa likes

    ReplyDelete

emo-but-icon

Follow Us

Recent

Comments

Donate

Side Ads

Text Widget

Connect Us

Sql Server 2017 Interview Questions
Sql Server Basic Interview Query Set-1
Sql Server Basic Interview Query Set-2
Sql Server Date-Time Interview Query SET-3
Sql Server Salary Interview Query SET-4
Sql Server Group By Interview Query SET-5
Sql Server Join Interview Query SET-6
Sql Server Tricky Join Interview Query SET-7
Sql Server DDL Interview Query SET-8
Small but very Tricky Sql Server Query SET-9
Very Much Tricky Query (not 4 fresher)SET-10
Sql Server Complex Interview Query SET-11
Sql Server Datatype Interview Questions
Sql Server View Interview Questions
Sql Server Index Interview Questions
TCS Tricky Sql Interview Queries
HCL Sql Interview Queries
Sql Server SP Interview Questions
Sql Server Trigger Interview Questions
Sql Server Temp Table Interview Questions
Sql Server 2016 Interview Questions
Sql Server Performance Tuning Interview Q.
Sql Server Constraints Interview Questions
Sql Server Storage/Size Interview Questions
Sql Server Very Basic Interview Questions
Sql Server Quiz for Fresher
Sql Server Icon Quiz for All
Sql Server 300+ Theoretical Interview Questions
Sql Server Complete Set

ASP.NET AND JQUERY INTERVIEW QUESTION
ASP.NET: Web Config Interview Question
ASP.NET: View State Interview Question
ASP.NET: Session Interview Question
ASP.NET: Session Interview Question 
ASP.NET: Security Interview Question
ASP.NET: Catching Interview Question
C# OOPS Interview Question
MORE Interview Question
JQUERY: Interview Question Set-1
JQUERY: Interview Question Set-2
JAVA-SCRIPT: Interview Question Set-1
JAVA-SCRIPT: Interview Question Set-2
ASP.NET MVC: Interview Question Set-1

POPULAR POSTS
10 MOST DIFFICULT INTERVIEW QUESTIONS
5 BEST INTERVIEW TIPS
YOUR 10 MISTAKE DURING INTERVIEW
2016 TOP 20 GROUP DISCUSSION TOPICS
HOW SQL PERFORMANCE AFFECTED BY DATATYPE
item