SQL Server Interview Questions
Basic SQL Server Interview Questions
SQL Server Interview Questions on Temporary Tables
SQL Server Interview Questions on Indexes - Part 1
SQL Server Interview Questions on Indexes - Part 2
What is the difference between a Temporary Table and a Table Variable
What is the use of COALESCE in SQL Server
SQL Server Interview Questions on triggers
Difference between User Defined Function and Stored Procedure
SQL Server Interview Questions on Views - Part 1
SQL Server Interview Questions on Views - Part 2
Basic SQL Server Interview Questions on Joins
Explain Inner Join with an example
Explain Left Outer Join with an example
Explain Right Outer Join with an example
Explain Full Outer Join with an example
Explain Self Join with an example
What is the difference between Index Scan and Index Seek
What are the advantages of using stored procedures?
What are the different ways to replace NULL values in SQL Server?
SQL Server interview questions on string manipulation functions
Write a Stored Procedure that takes column name as a parameter and returns the result sorted by the column that is passed
What is deferred name resolution in SQL Server?
Subscribe to:
Post Comments (Atom)
Dear Mr.Venkat,
ReplyDeleteThank u very much for such an organized collection. I cleared my interview after reading this blog for 2 times.
- Anup
Really nice collection of SQL Questions. Thanks for the nice post.
ReplyDeletePriya Sharma
Senior Software Engineer, Accenture
Hi there, awesome site. I thought the topics you posted on were very interesting. I tried to add your RSS to my feed reader and it a few. take a look at it, hopefully I can add you and follow.
ReplyDeleteHi Venkat,
ReplyDeleteThis is awesome zone, where i clear my fundamental concept to remember easily and getting confident to clear interview.
Thank you for your wonderful work!!
ReplyDeleteHi Mr Venkat,
ReplyDeleteThis is to thanks from bottom of heart for such a nice collection in one place , C#, ASP.NET, SQL SERVER tutorials and Interview questions all of them helping lot in my preparation . Keep doing hard wark . god bless you
Hi Mr Venkat
ReplyDeletethank you for your hard work second
i would like to ask quatsion i have problem in part 27 in sql server i have this code
DECLARE @DOB Datetime, @tempdate Datetime, @years int, @months int, @days int
SET @DOB='10/08/1982'
SELECT @tempdate = @DOB
SELECT @years = DATEDIFF(YEAR, @tempdate, GETDATE()) -
CASE
WHEN (MONTH(@DOB) > MONTH(GETDATE()) OR
(MONTH(@DOB) = MONTH(GETDATE()) AND DAY(@DOB) > DAY(GETDATE()))
THEN 1 ELSE 0
END
SELECT @tempdate = DATEADD(YEAR, @Years, @tempdate)
SELECT @months = DATEDIFF(MONTH, @tempdate, GETDATE())
CASE
WHEN DAY(@DOB) > DAY(GETDATE())
THEN 1 ELSE 0
END
SELECT @tempdate = DATEADD(MONTH, @months, @tempdate)
SELECT @days =DATEDIFF(day, @tempdate ,GETDATE())
SELECT @Years as Years, @months as Months ,@days as [Days]
Error messege is
Msg 156, Level 15, State 1, Line 10
Incorrect syntax near the keyword 'THEN'.
Msg 156, Level 15, State 1, Line 15
Incorrect syntax near the keyword 'CASE'.
Then will not exept in OR and AND
please teacher send me correct code in
my email f.bilaal0007@gmail.com
DECLARE @DOB Datetime, @tempdate Datetime, @years int, @months int, @days int
DeleteSET @DOB='10/08/1982'
SELECT @tempdate = @DOB
SELECT @years = DATEDIFF(YEAR, @tempdate, GETDATE()) -
CASE
WHEN (MONTH(@DOB) > MONTH(GETDATE()) OR
(MONTH(@DOB) = MONTH(GETDATE()) AND DAY(@DOB) > DAY(GETDATE())))
THEN 1 ELSE 0
END
SELECT @tempdate = DATEADD(YEAR, @Years, @tempdate)
SELECT @months = DATEDIFF(MONTH, @tempdate, GETDATE())-
CASE
WHEN DAY(@DOB) > DAY(GETDATE())
THEN 1 ELSE 0
END
SELECT @tempdate = DATEADD(MONTH, @months, @tempdate)
SELECT @days =DATEDIFF(day, @tempdate ,GETDATE())
SELECT @Years as Years, @months as Months ,@days as [Days]
DECLARE @DOB Datetime, @tempdate Datetime, @years int, @months int, @days int
ReplyDeleteSET @DOB='10/08/1982'
SET @tempdate = @DOB
Set @years = DATEDIFF(YEAR, @tempdate, GETDATE()) -
CASE
WHEN ((MONTH(@DOB) > MONTH(GETDATE()) OR
(MONTH(@DOB) = MONTH(GETDATE())))
AND (DAY(@DOB) > DAY(GETDATE())))
THEN 1
ELSE 0
END
SELECT @tempdate = DATEADD(YEAR, @Years, @tempdate)
SELECT @months = DATEDIFF(MONTH, @tempdate, GETDATE()) -
CASE
WHEN (DAY(@DOB) > DAY(GETDATE()) )
THEN 1
ELSE 0
END
SELECT @tempdate = DATEADD(MONTH, @months, @tempdate)
SELECT @days =DATEDIFF(day, @tempdate ,GETDATE())
SELECT @Years as Years, @months as Months ,@days as [Days]
Hello Sir,
ReplyDeleteCan i rename files place in folder through SQL query.
If Yes Please just upload a code . I'll be thankful to you.
The Problem is following..
• There is a folder with 100s of pictures i.e. 834343.jpg, 843244.jpg etc
• I need to update all files with the corresponding ID_NUMBER of the Personnel number attached to the photos (personnel number 834343).
• The table aview_person has two distinct columns (extra_code_1 which holds the values of the personnel numbers (834343, 843244 and so on etc)… The table also has a column ID_Number (001.344324233232432,002.34453453453453) which is the reference ID number which is associated to the value in extra_code_1.
• The pictures need to be updated with the ID_number and the extension. So the update once completed should look like this
o Original picture (843423.jpg)
o New Picture (001.334323432434234243.jpg)
• I need the query to loop through all photos can change to the corresponding ID Number
Query
DECLARE @ID_NUMBER NVARCHAR(27)
SELECT @ID_NUMBER = ID_NUMBER FROM aView_person WHERE EXTRA_CODE_1 ='photo name'
---PSEUDO---
update
'Photo name in File Path where photos are stored'
set'photo name'= @ID_NUMBER +'.JPG'
innerjoin aview_person per on'name of photo (without the .jpg extension)'= per.extra_code_1
where per.extra_code_1 ='photo name'
--Example--
---------Loop through all files in the folder until all files have been updated with the corresponding id_number'
update'C:/Test/' ---photos location
set'834567.jpg'='001.3434312759397368038'+'.jpg'
innerjoin aview_person per on'834567'= per.extra_code_1
where per.extra_code_1 ='834567'
I Search for the solution my best, but can't find .
Sir you are the only hope to help me. If it is possible then help me please.
This is one of the interview questions asked to me?
ReplyDeleteHow do you arrange data or what is procedure you apply to write code when a problem statement is given in 3 tier architecture?
Ex : Whether you will add tables,data etc in Database or Add code in Presentation layer to display in front end or Create Business objects in Business layer or Data Access Objects in DAL.. Tell me the order you follow ?
Kindly need an answer for this
Pls Help
Can you please explain about CTE?
ReplyDeleteHi,
ReplyDeleteCan you explain types of locks in SQL?
Hi Sir,
ReplyDeletehow do i grant privileges to specific user (based on role)
Hi venkat sir
ReplyDeletehow can we store videos, audios and images in sql server 2008 and 2012
Hi Venkat Sir,
ReplyDeleteI've got a query. I researched about this but didn't get a correct answer. following is the query.
Can it be a good practice to join all tables in the same order on all queries if at all possible ? Are the tables with switched orders between queries the most common cause of a deadlock. For example, selecting from Client table inner join Order table in one query and Order table inner join Client table in another query - if they get executed at the same time, is there a deadlock potential ? What can be a standard rule for this ? Can joining all tables in the same alphabetical order on all queries help ?
From : Sumit, sumitofficial7777@gmail.com
Hi Sir,
ReplyDeletewhat is #table and ##table, what is the difference between them and when we use it in real time.
Both, #Table and ##Table are temporary tables. #Table is only accessible to that particular user whereas ##Table is accessible to anyone who has access to that Database.
Deletei think we use it in query scripts we rarely use it and no need to save data that we want as a normal table.
ReplyDeleteHOW TO RECOVER DEADLOCK TRANSACTION ID PROCESS LOCK
ReplyDeleteHello Guy, A very big regard to Mr.Vankat
ReplyDeleteAll the way from African precisely Nigeria, I copied your tutorial videos on Microsoft SQL from a friend of mine.
It was a very good and excellent one.Your method of teaching is unique and classic. I pray that God will reward you and bless your family.