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
Well done, it must took you a good while to write these questions for the greater good
I was wondering when the interview articles will finish, so I can print them double-sided
now with the PDF, problem solved.
Many thanks Pinal, from Canada
Pinal,
This interview question pretty old, do you have interview question for SQL Server 2012?
please create a new one same as 2008
Good Idea.
Hi Pinal ,
i want to know how to Insert Excel file in binary format in perticular one Collum of sql Table.
Use varbinary(max) column and openrowset
INSERT INTO your_table(FileName, Document)
SELECT 'Text1.txt' AS FileName,
* FROM OPENROWSET(BULK N'C:your_excel.xls', SINGLE_BLOB) AS Document
But I would say it is better you store the file path to the table and keep the file in Server’s directory
hi…. madhivanan
i want to create query to insert a document like our CV or Resume when we retrieve it
INSERT INTO your_table(FileName, Document)
SELECT ‘Text1.txt’ AS FileName,
* FROM OPENROWSET(BULK N’C:your_excel.xls’, SINGLE_BLOB) AS Document
send me query to retrive word document through query.
when i fire a query
i hope u may respond me ASAP….
byeee
Regards
sanju
You need to use a front end application to open the document
I have to design a script which would go thru the DB and extract a flat file of each pertinent table’s data(1 file/table).I have used DTS to export data from databases.I have never written a script for extraction.Could you please guide me on this and help me in getting started on how to write a script with a small example.Could you also please help me on how to run the script against the database so that it could generate a data file
Do u usually reply to their email or post solutions here?
Thanks
Shveta
Hi Pinal,
Greatest work..Thanks a ton..You have made concepts clear to me..
Pramila
hi Pinal,
thanks a lot,……i think no book will give as much wealthy knowledge as your website gives…..this is the real place to learn a lot and that too your examples are amazing…..easy to understand and learn……..thanks a lot.
Dear
pinal
I am looking forward to change . so for that i need sql server 2005 question and answer
regards
karan
My SQL statements are:
CREATE TABLE doc_exe ( column_a INT CONSTRAINT column_a_un UNIQUE)
GO
ALTER TABLE doc_exe
alter column column_a int identity(1,1)
I get the error:
Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword ‘identity’.
Please explain or correct the sytax.
Thanx
It is not possible to alter the column to have identity property
One way is to drop the column and recreate it with identity property
Greatest work..Thanks
Hi Pinal,
I have table structure with data like below. all columns are key columns.
Col1 col2 col4
a1 c 1
b1 a 1
c1 b 1
d2 b 2
b2 c 2
c2 a 2
a2 d 2
b3 a 3
a3 d 3
But I want a query to get first record group by col4. the resultset should be
Col1 col2 col4
a1 c 1
d2 b 2
b3 a 3
Please guide me to get a query.
Thanks,
select col1,col2,col4 from
(
select *,row_number() over(partition by col4 order by col4) as sno from your_table
) as t
where sno=1
select max(col1),max(col2),col4 from a group by col4
hom many time takes to download sql server 2008 ?
Hi Pinal,
So nice of you. You are doing a very big help and guidance to people like me.
God bless You and your family.
Hello Sir,
The information there on this blog is very useful & helpful thanks for providing such informative infromation.
Sir i have a query in ms-sql server2000
can we convert numeric(18,0) to identity(1,1) which will be primary key ,
since this ID numeric(18,0) is a foreign key in another table so i wanted that this key should be as primary auto incrementing key
whereas i am also unable to do insert into statement for the same
error ocuuring is as : Cannot insert explicit value for identity column in table
Can you please help me out.
Smita,
You have to drop that column and recreate it with IDENTITY property and also we can not insert any value for Identity column
hi
i want to store a image in sql server 2005 by usging Sql command
plz guide me
It is better to store the image url in the table and physical images in the directory.
Hi Dave,
I’m very new to SQL server. Could you please guide with any training materials. Thank you
Dear Pinal Dave
Really your are doing marvels Job I would like to appreciate your effort and Pray from God you always maintain this effort for deprived person like me.
Regard
Muhammad Junaid Babar
Gr8 job dude..!
Girish Advani
Gujarat
Wonderful Work!
its helping me more to walk in interview
thanks for such a ……
like qus
Hi Pinal,
In your pdf, you have mentioned that “Update Statistics will updates indexes on tables” which is incorrect. Update statisitics will only update stats. For updating indexes you need to rebuild indexes.
Also you have mentioned that select rows from sysindexes is a accurate way of getting rowcount which is also incorrect. If statistics is outdated then this would not give you accurate result.
AD
To get correct rowcount, you need to run
DBCC Updateusage
But I think from version 2005 onwards this is taking care automatically
Hi Dave,
I’m very new to SQL server. I dont know anything about SQL.I am in SQL administrator destination.Could you please guide with any training materials. Thank you
Regards,
Krishna
If you are more concerned about wring t-sql, first lean sql. Search for “Learn SQL” in Google/Bing