Books MVC ASP.NET C# SQL Server WCF Written Test HR Round Subscribe SQL Tutorial C# Programs Support Us

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?

9 comments:

  1. Dear Mr.Venkat,
    Thank u very much for such an organized collection. I cleared my interview after reading this blog for 2 times.

    - Anup

    ReplyDelete
  2. Really nice collection of SQL Questions. Thanks for the nice post.

    Priya Sharma
    Senior Software Engineer, Accenture

    ReplyDelete
  3. 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.

    ReplyDelete
  4. Hi Venkat,

    This is awesome zone, where i clear my fundamental concept to remember easily and getting confident to clear interview.

    ReplyDelete
  5. Thank you for your wonderful work!!

    ReplyDelete
  6. Hi Mr Venkat,
    This 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

    ReplyDelete
  7. Hi Mr Venkat
    thank 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

    ReplyDelete
  8. DECLARE @DOB Datetime, @tempdate Datetime, @years int, @months int, @days int
    SET @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]

    ReplyDelete
  9. Hello Sir,
    Can 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.

    ReplyDelete

If you are aware of any other sql server questions asked in an interview, please post them below. If you find anything missing or wrong, please feel free to correct by submitting the form below.

 
Disclaimer - Terms of use - Contact Us