Top 6 SQL Tricky Interview Questions & Answers | sql server interview question and answers

preview_player
Показать описание
Top 6 SQL Tricky Interview Questions & Answers | Accenture SQL Interview Questions | Part 49

Top SQL interview questions and answers for freshers and professionals in 2021. These questions have been designed to help you become more comfortable with the types of questions you might be asked during your SQL interview.

Accenture SQL Questions and Answers 2020

For SQL Quiz-

Find Us On FaceBook-
Комментарии
Автор

----Question--1

declare @input



declare @source table(id int)
declare @dest table(id int)

insert @source values (1), (1)
select * from @source

Merge @dest as D
Using @Source as S
On s.id=d.id
When Matched Then
Update Set d.id=s.id
When Not Matched by Target then
Insert (id) Values (s.id);

select * from @dest



SELECT LEN('SS UNITECH')-LEN(REPLACE('SS UNITECH', 'S', ''))



DECLARE @ATT TABLE (EMP INT, DATEPRESENT VARCHAR(50))
INSERT @ATT VALUES (1, '1, 2, 3'), (2, '2, 4, 5, 6'), (3, '1, 2, 5, 4, 7, 9')

SELECT *, LEN(DATEPRESENT)-LEN(REPLACE(DATEPRESENT, ', ', '') )+1
FROM @ATT



DECLARE @TBL TABLE(ID VARCHAR(100), NAME VARCHAR(100))
INSERT @TBL VALUES(1, 'AA'), (2, 'BB'), (3, 'CC')

SELECT * FROM @TBL

UPDATE @TBL
SET ID=NAME, NAME=ID

SELECT * FROM @TBL



DECLARE @I INT=100

;WITH CTE AS
(SELECT 1 AS ID
UNION ALL
SELECT ID+1
FROM CTE
)
SELECT * FROM CTE

ssunitech
Автор

Hello Sir, I think for length function question we can directly use length(replace()), no need to use - operator then again needs to add 1

THERANGERWOLF
Автор

For column swapping no need to update we can go with case statement like below
SELECT (CASE WHEN ID=ID THEN NAME END) AS ID,
(CASE WHEN NAME =NAME THEN ID END) AS NAME FROM TABLE NAME;

shivaroyal
Автор

Hi Sir
can you please share the complete SQL classes, i have not found in playlist, if not please starts classes sir.
most of the interviews they are asking SQL logic quries.

anithaanitha-gb
Автор

Wow it's great video and very helpful...
Hope you will upload more videos

sandhyasingh
Автор

Very Informative and crispy. Appreciated and Thanks for sharing the knowledge.

selvakumar
Автор

Thanks for the tricky sql interview questions and answers...
for q4....select EMP, len(replace(DATEPRESENT, ', ', ''))
from @ATT....
will also work?

rajsamant
Автор

Second question regarding merge, first 1 will be not matched, so insert to destination, but 2nd 1 should be matched, thus it should be a update, so should it be only one row returns from @dest?

bellajoyrossa
Автор

Please create more videos like this, good work

EnjoyYOu
Автор

Question: 'ABC, , ,, ,CDB,, , BTBGB, , , ,VEDR '
Ans:
declare @input2 varchar(100) = 'ABC, , ,, ,CDB,, , BTBGB, , , ,VEDR '

Small modification based on your question Sir. Thank you.

prameeSri
Автор

Nice video really helpful to get list of question and answer..
These are really very common question 2 questions were asked by me as well..
Keep it up..

roshnisingh
Автор

Short & Precise
Completely understood in 12 mins.
Request you to please upload some videos of C# use in SSIS.

Raj-phpy
Автор

Love this video.. thank you .. pls keep the good work going on

sumitshitole
Автор

Nice explanation never seen before and ever after...

Naveen_Kumar_Garikipati
Автор

I think Q 5 should be wrong.

UPDATE @TBL
SET ID=NAME, NAME=ID

Once you set the ID column to have value of the NAME then the value of ID itself should be lost. Which means both columns now should have the NAME value.
Could you please help me (and other) on that.

Thank you.

iliashterev
Автор

To the point explanation... 👍Keep it up

premaliadkar
Автор

Q5 :- How to swap the column if the ID is int and Name is varchar ??

himanshubajaj
Автор

Thanks!
Could you please tell or make a video on recent accenture sql server application developer Online test and interview questions for 3 yers experience. It will be really helpful.

rafixa
Автор

Appreciate your efforts.. keep it up!!

sandeepkhawas
Автор

declare @name varchar(200) = 'SS aS UNITECH S'

Output : 5

AmitKalshetti