Interview Questions and Answers are now updated with the latest questions and answers. New Location: SQL Server Interview Questions and Answers.
Click here to get free chapters (PDF) in the mailbox
Thank you all for your appreciation about the my recent series of SQL Server Interview Questions and Answers. I enjoyed writing questions and answers. I have gotten many emails about complete series.
Top most requests were to collect series in one big post so they can be easily used. I was asked to provide links to download them so they can be printed and referred.
Another question I received is done I ask the same questions in interviews which I administrate. The answer is YES. Though, I have a few other questions, which I ask. All of them, I came up myself and answers are unique to questions and not available on-line. Well, long story short, I have compiled list of questions in one PDF. Please download them and use them in your next interview or just for reading purpose.
An interview Question and Answer discussion can be very helpful 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.
Download SQL Server Interview Question and Answers Complete List
Complete Series of SQL Server Interview Questions and Answers
Introduction, Part 1, Part 2, Part 3, Part 4, Part 5, Part 6
SQL Server Interview Question and Answers Complete List Download
Other popular Series
SQL SERVER Database Coding Standards and Guidelines Complete List Download
SQL SERVER – Data Warehousing Interview Questions and Answers Complete List Download
Connect with me on Twitter.
Reference: Pinal Dave (https://blog.sqlauthority.com)
282 Comments.
Question about user
Could you help me find all user in sql database by using script.
kao
thanks a lot!!!
Thnx man.. nce wrk.. :)
sir,
This is suresh. can u tell about data modelling.
Hi,
Information from this site is helping a lot ….
can you please describe the new programming features from Sql Server 2008.
Thanks,
Hi Dave,
I have a question. How can I pull the area codes from the following list of phone numbers in a table?
1-630-832-3215
(567)453-1234
546-234-2456
342234567
Your help will be greatly appreciated
Thanks
George
hi Pinal,
its been very good knowledge sharing .
its realy a good update for me in SQL.
thanks.
brijesh patel.
Hi Dave,
This is really good site for all sql server users.
I have questions what is good Cursor or while loop.
I read cursor is beter how can u help me?
Thanks.
Vinit gaur
Hi friend,
This is Rajesh . I am looking for job only in SQL Server… Is it possible to get job in SQL server.. I am working in SQL for 1 + year. s it possible ?
Hi
Your website is very usefull. Can you please post some list of interview question on SSIS too.
Thanks
What is the difference in Procedure and Function in detail. Can we use output parameters in function?
Hi guys
how to retrive the prvious year to current year(for example today date is mach-2007 then it retrive march2007 to march 2006) please help me
Hi Keerthi
Check this,
SELECT DATEADD(Year,-1,GETDATE())
Hi Abhishek Srivastava,
Procedure is a saved block of statements that can take and return user-supplied parameters.
Function is block of statements (routine) that only returns a value.
SQL function returns a value, where as a procedure does not
‘OUTPUT’ option can be used with ‘create procedure’ to specify return parameter
It cannot be used with ‘create function’ query
Regards,
Hi Kao,
Try this to find all user in sql database by using script in sql server 2005(Select Master database)
Select name from sys.login_token
In SQL Server 2000 u need to check syslogin table in Master database
Regards,
HI Kao,
U can also get it using
select name from sys.sql_logins
This will give u list of users (excluding SQL users like ‘public’)
Hi Pinale!
First of all I congrates to you for your achievement as MVP. May be am very laet to reach here but I thought I have reached here.
There is no doubt this is a good site and its really helpful to peoples like me.
Basically, I am .Net Developer but like to work with SQL using its stuff. And today, I have found your site which meets my requirements. I have opted some posts to my site –
I think as a Technical guy, I need to add more stuff in my Technical skills.
Your comments awaited towards my thinking and may be I was wrong?
Keep it up dear!
Thanks,
Gaurav Arora
Guys I have few queries
A.
Here is the code
1. if exists(Select count(*) from emp where deptno=20)
2. goto sales_pro
3. else
4. goto notexists_pro
5.
6. sales_pro:
7. begin
8. print ‘ I am in sales_pro !’
9. select * from emp where deptno=20
10. end
11. notexists_pro:
12. begin
13. print ‘ I am in notexists_pro’
14. print ‘sorry no employee exists’
15. end
Query:
if the control goes in ‘6. sales_pro:’ label, after executing upto line 10, it continues with the ’11. notexists_pro:’ label staments. How to break / stop the execution at line 10?
B.
Can I alter the existing column of the table, and add Identity(1,1), if there is no row inserted in the table?
Plz let me know
@Swati
Your first question.
I have no idea why you are using that terminology, when you can use a simple while loop with break. This would solve the problem. Again I think I did not understand your question properly.
Your second Questions.
YOU can add identity column to a table after you create a table, which has no records or which has some records. Yes You can still add a identity column if your table has records ( data ) in it.
For sure you cannot do this through query analyzer or code.
You can only do this through Enterprise manager or object explorer in SSMS ( 2005).
Select the table in which you want to create an identity column, right click table – > click modify -> create a new column, select the datatype , int, smallint, bigint… ( no characters) and below in column properties scroll down a little bit and you can see identity specifications, expand that and click on the cell and you should be able to see an option YES. Select it and click save and you are good to go.
This will create an identity column in the table, but if there exists some previous data inside the table… identity column will select its values automatically, depending upon your seed.
Hope this helps.
Thanks,
Imran.
Thanks Imran!
Regards,
Swati