Write a stored procedure for emplpoyee and department table
to get DeptName which having no employee.
Table Structure-
Emp-Emp_Id,Emp_Name,Dept_id
Dept-Dept_Id,Dept_Name

Answers were Sorted based on User's Feedback



Write a stored procedure for emplpoyee and department table to get DeptName which having no employ..

Answer / madhuparna bhaumik

/*stored procedure for emplpoyee and department table
to get DeptName which having no employee*/

CREATE PROCEDURE sp_myStoredProcedure
AS
select * from emp full join departments on
emp.department_id=departments.department_id
where employee_id is null;
Go

Is This Answer Correct ?    9 Yes 0 No

Write a stored procedure for emplpoyee and department table to get DeptName which having no employ..

Answer / vinoth kumar

select * from department where Dept_id
not in(select Dept_id
from employee)

Is This Answer Correct ?    4 Yes 0 No

Write a stored procedure for emplpoyee and department table to get DeptName which having no employ..

Answer / ayush

create proc DeptName
begin
select * from emp full join dept on emp.deptno=dept.deptno
where empno is null;
end

Is This Answer Correct ?    3 Yes 0 No

Write a stored procedure for emplpoyee and department table to get DeptName which having no employ..

Answer / sivaram pothuru

select * from emp full join dept on emp.deptno=dept.deptno
where empno is null;

Is This Answer Correct ?    4 Yes 3 No

Write a stored procedure for emplpoyee and department table to get DeptName which having no employ..

Answer / unnikrishnan nair r

CREATE PROCEDURE GetDept
AS
SELECT Dept_name from dept
WHERE Dept_Id NOT IN(SELECT DISTINCT Dept_id FROM Emp )

Is This Answer Correct ?    1 Yes 1 No

Write a stored procedure for emplpoyee and department table to get DeptName which having no employ..

Answer / sql pro

/*stored procedure for emplpoyee and department table
to get DeptName which has no employee records*/

select d.dept_name
from dept d
left join empl e
on d.dept_id = e.dept_id
where e.dept_id is null

Is This Answer Correct ?    1 Yes 1 No

Write a stored procedure for emplpoyee and department table to get DeptName which having no employ..

Answer / sivaram pothuru

select a.*,d.* from dept a
left join emp d on a.deptno=d.deptno where d.deptno is null

Is This Answer Correct ?    4 Yes 5 No

Post New Answer

More SQL Server Interview Questions

Explain insert into select statement?

0 Answers  


Does union all remove duplicates?

0 Answers  


What is the exact numeric data type in sql?

0 Answers  


Which virtual table does a trigger use?

8 Answers   TCS,


What is the difference between stored procedure and user defined functions?

0 Answers  






How can you ensure that the database and sql server based application perform well?

0 Answers  


Where sql server user names and passwords are stored in sql server? : sql server database administration

0 Answers  


Suppose i have one sql query that contains 2 minute to execute.After one weekly i am executing same query that is taking 5 minute.Why our same query is taking more time.what would be my approach to reduce execution time.Please help.

1 Answers   Cognizant, HCL, Value Labs,


What are the default system databases in sql server 2000?

0 Answers  


What is stored procedures?

0 Answers  


What are the disadvantages of primary key and foreign key in SQL?

0 Answers   Alcatel-Lucent,


What are different types of replication in sql server?

0 Answers  


Categories