The interview is a very important event for any person. A good interview leads to good career if the candidate is willing to learn. I always enjoy interviewing questions and answers series. This is my very humble attempt to write SQL Server 2008 interview questions and answers. SQL Server is a very large subject and not everything is usually asked in interview. In interview what matters the most is the learning attitude.
Interview Questions
An interview Question and Answer discussion can be beneficial to both these individuals. It is simply a way to go back over the building blocks of a topic. Many times a simple review like this will help “jog” your memory, and all those previously-memorized facts will come flooding back to you. It is not a way to re-learn a topic, but a way to remind yourself of what you already know.
I have listed all the series in this post so that it can be easily downloaded and used. All the questions are collected and listed in one PDF which is here to download. If you have any question or if you want to add to any of the questions, please send me a mail or write a comment about interview questions.
Click here to get free chapters (PDF) in the mailbox
You can also connect with me on Twitter.
Reference: Pinal Dave (https://blog.sqlauthority.com)
160 Comments. Leave new
Hi Sir
Can you send me the sql server 2008 s/w link to my mail-id
please…
Hi Pinal,
Is there any levels for Recursive CTE like stored procedures?
How many levels we can go?
Thanks,
Anand
It can go to any level but you need to specify the max recursion option to 0
Hi Pinal,
Thanks for putting this together. However I’m having a problem printing the PDF.
It’s security protected (DRM) preventing it from being copied or printed.
Thanks
Adam,
did you ever get a reply?
Thanks a Million
It’s Really Gr8 Job
Good job dude.
Questions are very good but answer does not sound good.
Any how gr8 work.
Hi Sir,
I have done mcom i was working as mis reporting in excel , company got relocated i was in search of job someone suggested me do course in oracle DBA …I finished my course can u suggest me how shld i study… and prepare for interview and pls send me interview question to my mail id….pls i am physically challenge girl i am struggle to find job…
Thanks for this post; it’s really helpful.
HELLO SIR,
HOW TO MAKE UNION OF “2 IF CONDITION” QUERIES?
FOR EXAMPLE:
IF(J=J)
BEGIN
SELECT ID,* FROM TABLE1
END
UNION
IF(I=I)
BEGIN
SELECT ID,* FROM TABLE2
END
WITH GROUPBY ID
Put the IF condition in the WHERE clause of each query
sir,
What is difrrences in sql server backup and windows backup.
hi., some one plz suggest me a project on Oracle 10g (for B.tech final year project)
Great work, good basic set of questions. It is great that I can download them. I can see preventing the changing of the document, but preventing the printing is a little overboard. if I can download, why cant I print?
I use your questions a a reference point to what topics I really want to touch on during an interview. I do not always have a computer nearby.
Pinal you are king of SQL and SQL server!
amazing website, thanks for sharing your knowledge with us
cheers
C
Hi,
In Change Data Capture What is Diffrence Between $start_lsn And $eqval
Hi
After creating the cdc (table_CT) table that is genrated in system table cant Be Modified Means It Dosnt have Design option in sql server 2008
Can Anybody Give Me Solution For This
Hi,
I am using SQL SERVER 2008 R2. In that i was created the job for taking the back up. It was working from the day of it is created. But from the last week it was not executed and also it shows error” Execution Failed.,See the Maintanence Plan and SQL Server Agent Job History logs for details”
Please let me know why it happens? What is the solution to resolve this?
See if the SQL Server agent is running. Also check if the password got changed for the account that runs a job
Is it possible to add an application develped in VB.net & SQLServer2008 to system startup..???
why we use indexes in sql server 2008. please let me know in detail.
Hi pinal,
This is good for fresh people who just learn sql server and want to job as developer.
But pinal , I am looking for some technical interview question with answer and some technical example as well.
Because in some job people take interview with situation , action and result.
I am looking that kind of interview question and answer.
Hi Pinal,
I’m having a very hard time in findig a way to enter my @FromDate and @ToDate into my procedure…can you please help and show me where do i need to enter these. Thank you so much in advance
CREATE Procedure dbo.UHS_Rapidresponsedoc_RS_PR
(@JobId int
)
as
Begin
Set NoCount on
Declare @FromDate DATETIME
Declare @ToDate DATETIME
Declare @SubmittedReportGUID HVCIDdt
DECLARE @InputParamTable TABLE
(
InternalValueGUID VARCHAR(30),
ValueFrom VARCHAR(255),
Name VARCHAR(30)
)
SET @SubmittedReportGUID = (SELECT
SubmittedReportGUID
FROM HVCRequestedReport
WHERE JobID = @JobId)
INSERT INTO @InputParamTable
SELECT InternalValueGUID,
ValueFrom,
Name
FROM HVCSubmittedParameter
WHERE SubmittedReportGUID = @SubmittedReportGUID
–Select * from @InputParamTable
— Get the Report Date Intervals
SELECT @FromDate =
CASE
WHEN LEFT(RP.ValueFrom,1) = ‘t’ AND LEN(RP.ValueFrom) = 1 THEN
CONVERT(varchar(11), GetDate())
WHEN LEFT(RP.ValueFrom,1) = ‘t’ AND PATINDEX(‘%+%’,RP.ValueFrom) 0 THEN
DATEAdd(dd,convert(numeric,LTRIM(RIGHT(RP.ValueFrom,LEN(RP.ValueFrom)-PATINDEX(‘%+%’,RP.ValueFrom)))),CONVERT(datetime,CONVERT(varchar(11),GetDate())))
WHEN LEFT(RP.ValueFrom,1) = ‘t’ AND PATINDEX(‘%-%’,RP.ValueFrom) 0 THEN
DateAdd(dd,-convert(numeric,(LTRIM(RIGHT(RP.ValueFrom, LEN(RP.ValueFrom)-PATINDEX(‘%-%’,RP.ValueFrom))))),CONVERT(datetime,CONVERT(varchar(11),GetDate())))
ELSE CONVERT(datetime,RP.ValueFrom)
END
from @InputParamTable RP
where RP.Name = ‘HVCFromDate’
SET @FromDate = CAST((SELECT @FromDate
) + ‘ ‘ + (SELECT
ISNULL(ValueFROM, ’00:00’)
FROM @InputParamTable
WHERE Name = ‘HVCFROMTime’) AS DATETIME)
SELECT @ToDate =
CASE
WHEN LEFT(RP.ValueFrom,1) = ‘t’ AND LEN(RP.ValueFrom) = 1 THEN
CONVERT(varchar(11), GetDate())
WHEN LEFT(RP.ValueFrom,1) = ‘t’ AND PATINDEX(‘%+%’,RP.ValueFrom) 0 THEN
DateAdd(dd,convert(numeric,LTRIM(RIGHT(RP.ValueFrom,LEN(RP.ValueFrom)-PATINDEX(‘%+%’,RP.ValueFrom)))),CONVERT(datetime,CONVERT(varchar(11),GetDate())))
WHEN LEFT(RP.ValueFrom,1) = ‘t’ AND PATINDEX(‘%-%’,RP.ValueFrom) 0 THEN
DateAdd(dd,-convert(numeric,(LTRIM(RIGHT(RP.ValueFrom, LEN(RP.ValueFrom)-PATINDEX(‘%-%’,RP.ValueFrom))))),CONVERT(datetime,CONVERT(varchar(11),GetDate())))
ELSE CONVERT(datetime,RP.ValueFrom)
END
from @InputParamTable RP
where RP.Name = ‘HVCToDate’
SET @ToDate = CAST((SELECT @ToDate
) + ‘ ‘ + (SELECT
ValueFROM
FROM @InputParamTable
WHERE Name = ‘HVCToTime’) AS DATETIME)
select cv.providerdisplayname
,u.displayname as authoredprovider
,cv.clientdisplayname
,cv.idcode
,cv.visitidcode
,cd.createdwhen
,cd.documentname
,cd.AuthoredDtm
,cd.ArrivalDtm
,cp.DisplayName
from cv3clientdocument cd
inner join cv3clientvisit cv
on cd.clientvisitguid = cv.guid
inner join cv3user u
on cd.authoredproviderguid = u.guid
inner join cv3careprovider cp
on cv.providerdisplayname = cp.displayname
where cd.documentname not like ‘%Phone%’
and cv.clientdisplayname not like ‘TEST%’
and cd.documentname like ‘%Rapid%’
and dateadd(dd, datediff(dd, 0, cd.ArrivalDtm ), 0) <= dateadd(dd, datediff(dd, 0, GETDATE()), 0)
and cd.ArrivalDtm between @FromDate and @ToDate
order by providerdisplayname,u.displayname,clientdisplayname
Set NoCount off
end
sir,
please tell me what are the main differences between ms access and sqlserver . when to use both different application?