Every interviewer has some favorite questions that he likes to ask in almost each and every interview. Here are some of mine, and a bit of advice for those who think these are easy, I would hold off on the answers till next week for you to try and take a guess at the answers (Without executing the commands on SQL Server, of course)
1. The Setup :
Employee
- EmployeeId int
- EmployeeName nvarchar(50)
- Sex ( constraint M / F) char(1)
- DepartmentId int
The requirement is to produce the following output in an optimized way
DepartmentId CountFemale CountMale EmployeeCount
2. The Setup :
USE PlayGround
GO
BEGIN TRAN
Create Table Employee
(
EmployeeId int
,EmployeeName nvarchar(100)
)
exec xp_cmdshell ‘bcp Playground.dbo.Employee in c:\Employee.txt -E -c’
TRUNCATE TABLE Employee
ROLLBACK TRAN
GO
SELECT * FROM Employee
GO
What is the expected result of the above script ?
3. A variation on the above :
USE PlayGround
GO
Create Table Employee
(
EmployeeId int
,EmployeeName nvarchar(100)
)
Insert Into Employee Select 1, ‘TestEmployee’
GOBEGIN TRAN
TRUNCATE TABLE Employee
ROLLBACK TRAN
GO
SELECT * FROM Employee
4. Is it possible to insert into two tables having same structure using a single insert statement ?

![Cento per farne una [EXPLORE] Cento per farne una [EXPLORE]](http://static.flickr.com/7155/6845993701_096381fb6e_t.jpg)





![Falling snow [Explored #22] Falling snow [Explored #22]](http://static.flickr.com/7004/6845839047_de1511ac1c_t.jpg)


Find all SQL server question and answers at:
http://subratac999.blogspot.com/2010/12/sql-server-interview-questions.html
Hey, Nice post. I have researched some Excellent HR interview questions and answers