-
UNIVERSITY ADMINISTRATION SYSTEM 1. Create a table with name
person with columns PersonID, lastname, firstname, Hiredate,
Enrollmentdate, Discriminator Apply Primary key for personID?
A:-create table person(personid varchar(30) primary key,lastname
varchar(30),firstname varchar(30),hiredate date,enrollmentdate
date,discriminator char(1))
2. Create a Table with name Department with columns
Departmentid, Name, Budget, startdate, personid Apply Primary key
for Departmentid and Foreign key for personid ? A:-create table
department(departmentid varchar(10) primary key,name
varchar(30),budget money,startdate date,personid varchar(30)
foreign key references person(personid))
3. Create a table with name course with columns courseid, title,
credits, departmentid Apply primary key for Courseid and foreign
key for departmentid? A:-create table course(courseid varchar(30)
primary key,title varchar(30),credits int,departmentid varchar(10)
foreign key references department(departmentid))
-
4. Create a table with name office Assignment with columns
personid and location Apply foreign key for personid? A:-create
table officeassignment(personid varchar(30) foreign key references
person(personid),location varchar(30))
5. Create a table with name courseinstructor with columns
courseid and personid Apply composite primary key for courseid and
personid and apply foreign key constraint for courseid and
personid? A:-create table courseinstructor(courseid varchar(30)
foreign key references course(courseid),personid varchar(30)
foreign key references person(personid) primary
key(courseid,personid)
-
6. Create a table with name enrollment with columns
enrollmentid, courseid, personid, grade Apply primary key
constraint for enrollmentid and foreign key constraint for
personid? A:-create table enrollment(enrollmentid varchar(30)
primary key,courseid varchar(30),personid varchar(30) foreign key
references person(personid),grade int)
7. WAQ to display person details. A:-select * from person
8. WAQ to display person firstname and lastname. A:-select
firstname+' '+lastname as 'Full Name' from person
-
9. WAQ to display Instructor Names. A:- select firstname+'
'+lastname as 'Instructor Name' from person where
discriminator='i'
10. WAQ to display Student Names. A:-select firstname+'
'+lastname as 'Student Name' from person where
discriminator='s'
11. WAQ to display Dept Names. A:-select name as 'Department
Name' from department
12. WAQ to display the no of employees working in Maths Dept.
A:-a)select count(distinct ci.personid) as 'No.of Employees' from
department d inner join course c on d.departmentid=c.departmentid
inner join courseinstructor ci on c.courseid=ci.courseid where
d.name='maths'
-
b)select count(distinct personid) as 'No.of Employees' from
courseinstructor where courseid in(select courseid from course
where departmentid in (select departmentid from department where
name='maths'))
13. WAQ to display the budget assigned for Maths dept A:-select
budget from department where name='maths'
14. WAQ to display depthead for Maths dept. A:-a)select
p.firstname+' '+p.lastname as 'HOD' from department d inner join
person p on d.personid=p.personid where d.name='maths' b)select
firstname+' '+lastname as 'HOD' from person where personid
in(select personid from department where name='maths')
15. WAQ to display the Student Names belonging to IT dept.
A:-a)select p.firstname+' '+p.lastname as 'Student Name' from
department d inner join course c on d.departmentid=c.departmentid
inner join enrollment e on c.courseid=e.courseid inner join person
p on e.personid=p.personid where d.name='it' b)select firstname+'
'+lastname as 'Student Name' from person where personid in(select
personid from enrollment where courseid in (select courseid from
course where departmentid in (select departmentid from department
where name='it')))
16. WAQ to display the CourseNames. A:-select title from
course
-
17. WAQ to display Course Names from IT department. A:-a)select
c.title as 'Course Name' from department d inner join course c on
d.departmentid=c.departmentid where d.name='it' b)select title as
'Course Name' from course where departmentid in (select
departmentid from department where name='it')
18. WAQ to display the no of courses that are available in IT
dept. A:-a)select count(c.courseid) as 'No.of Courses' from
department d inner join course c on d.departmentid=c.departmentid
where d.name='it' b)select count(courseid) as 'No.of Courses' from
course where departmentid in (select departmentid from department
where name='it')
19. WAQ to count the no of departments available in University.
A:-select count(departmentid) as 'No.of Departments' from
department
20. WAQ to display no of courses available in each dept.
A:-select d.name as 'Department Name',count(c.courseid) as 'No.of
Courses' from department d inner join course c on
d.departmentid=c.departmentid group by d.name
-
21. WAQ to display course names starting with c. A:-select title
as 'Course Name' from course where title like 'c%'
22. WAQ to display the Instructor Names who is teaching c.
A:-a)select p.firstname+' '+p.lastname as 'Instructor Name' from
course c inner join courseinstructor ci on c.courseid=ci.courseid
inner join person p on ci.personid=p.personid where c.title='c'
b)select firstname+' '+lastname as 'Insructor Name' from person
where personid in (select personid from courseinstructor where
courseid in (select courseid from course where title='c'))
23. WAQ to display Instructor Names who are teaching c and c++.
A:-a) select distinct(p.firstname+' '+p.lastname) as 'Instructor
Name' from course c inner join courseinstructor ci on
c.courseid=ci.courseid inner join person p on
ci.personid=p.personid where c.title='C' or c.title='C++' b) select
firstname+' '+lastname as 'Instructor Name' from person where
personid in (select personid from courseinstructor where courseid
in (select courseid from course where title='c' or
title='c++'))
-
24. WAQ to display StudentNames starting with p. A:-select
firstname+' '+lastname as 'Student Name' from person where
discriminator='s' and firstname like 'p%'
25. WAQ to update student firstname from yogesh to rohit.
A:-update person set firstname='rohit' where firstname='yogesh' 26.
WAQ to display DeptHeads from each Dept. A:-select d.name as
'Department Name',p.firstname+' '+p.lastname as 'HOD' from
department d inner join person p on d.personid=p.personid
27. WAQ to display the courses taught by sai. A:-a)select title
as 'Course Names' from person p inner join courseinstructor ci on
p.personid=ci.personid inner join course c on
ci.courseid=c.courseid where p.firstname='sai' b)select title as
'Course Names' from course where courseid in(select courseid from
courseinstructor where personid in(select personid from person
where firstname='sai'))
28. WAQ to display the student details who are Enrolled in Maths
Dept. A:-a)select distinct(p.firstname),p.lastname,p.enrollmentdate
from department d inner join course c on
d.departmentid=c.departmentid inner join enrollment e on
c.courseid=e.courseid inner join person p on e.personid=p.personid
where d.name='maths' b)select firstname,lastname,enrollmentdate
from person where personid in (select personid from enrollment
where courseid in (select courseid from course where departmentid
in (select departmentid from department where name='maths')))
-
29. WAQ to display dept names whose no of courses is >2?
A:-select d.name as 'Department Name',count(c.courseid) as 'No.of
Courses' from department d inner join course c on
d.departmentid=c.departmentid group by d.name having
count(courseid)>2
30. WAQ to display student name, Deptname and EnrollmentDate.
A:-select distinct(d.name) as 'Department Name',p.firstname+'
'+p.lastname as 'Student Name',p.enrollmentdate from department d
inner join course c on d.departmentid=c.departmentid inner join
enrollment e on c.courseid=e.courseid inner join person p on
e.personid=p.personid
31. WAQ to display the no. of courses learning by Kiran.
A:-a)select count(courseid) as 'No.of Courses' from person p inner
join enrollment e on p.personid=e.personid where firstname='kiran'
b)select count(courseid) as 'No.of Courses' from enrollment where
personid in (select personid from person where
firstname='kiran')
32. WAQ to display the CourseNames learning by Kiran.
A:-a)select c.title as 'Course Names' from person p inner join
enrollment e on p.personid=e.personid inner join course c on
e.courseid=c.courseid where p.firstname='kiran' b)select title as
'Course Names' from course where courseid in (select courseid from
enrollment where personid in (select personid from person where
firstname='kiran'))
-
33. WAQ to display the no of subjects teaching by sai.
A:-a)select count(courseid) as 'No.of Courses' from person p inner
join courseinstructor ci on p.personid=ci.personid where
p.firstname='sai' b)select count(courseid) as 'No.of Courses' from
courseinstructor where personid in (select personid from person
where firstname='sai')
34. WAQ to display the list of course name taught by suresh.
A:-a)select c.title as 'Course Names' from person p inner join
courseinstructor ci on p.personid=ci.personid inner join course c
on ci.courseid=c.courseid where firstname='suresh' b)select title
as 'Course Names' from course where courseid in (select courseid
from courseinstructor where personid in (select personid from
person where firstname='suresh'))
35. WAQ to display Instructor Name & office Location
A:-select p.firstname+' '+p.lastname as 'Instructor
Name',o.location from person p inner join officeassignment o on
p.personid=o.personid
36. WAQ to display student name who enrolled for course 'C'
A:-a)select p.firstname+' '+p.lastname as 'Student Name' from
course c inner join enrollment e on c.courseid=e.courseid inner
join person p on e.personid=p.personid where c.title='C'
-
b)select firstname+' '+lastname as 'Student Name' from person
where personid in (select personid from enrollment where courseid
in (select courseid from course where title='c'))
37. WAQ to display student firstname, lastname and Enrollment
date. A:-select firstname,lastname,enrollmentdate from person where
discriminator='s'
38. WAQ to display no of students Enrolled on 09/01/2013.
A:-select count(personid) as 'No.of Students' from person where
enrollmentdate='09/01/2013'
39. WAQ to display student name who enrolled for course 'java'
A:-a)select p.firstname+' '+p.lastname as 'Student Name' from
course c inner join enrollment e on c.courseid=e.courseid inner
join person p on e.personid=p.personid where c.title='java'
b)select firstname+' '+lastname as 'Student Name' from person where
personid in (select personid from enrollment where courseid in
(select courseid from course where title='java'))
40. WAQ to apply constraint primary key for Courseid and
Personid in CourseInstructor table. A:-alter table courseinstructor
add primary key(courseid,personid) 41. WAQ to count no. of credits
assigned for IT dept. A:-a)select sum(c.credits) as 'No.of Credits'
from department d inner join course c on
d.departmentid=c.departmentid where d.name='it'
-
b)select sum(credits) as 'No.of Credits' from course where
departmentid in (select departmentid from department where
name='it')
42. WAQ to display course name and instructor name A:-select
c.title as 'Course Name',p.firstname+' '+p.lastname as 'Instructor
Name' from person p inner join courseinstructor ci on
p.personid=ci.personid inner join course c on
ci.courseid=c.courseid
43. WAQ to display courseid, coursename, deptname and credits.
A:-select c.courseid,c.title as 'Course Name',c.credits,d.name as
'Department Name' from department d inner join course c on
d.departmentid=c.departmentid
44. WAQ to count no of instructors working in each department.
A:-select d.name as 'Department Name',count(c.courseid) as 'No.of
Instructors' from department d inner join course c on
d.departmentid=c.departmentid group by d.name
-
45. WAQ to display who enrolled for course 'C' order by
coursename. A:-select distinct(p.firstname+' '+p.lastname) as
'Student Name',c.title from course c inner join enrollment e on
c.courseid=e.courseid inner join person p on e.personid=p.personid
where c.title='c' order by c.title
46. WAQ to display course name starting with c. A:-select title
as 'Course Name' from course where title like 'c%'
47. WAQ to display instructor name, location, deptname and
coursename. A:-select p.firstname+' '+p.lastname as 'Instructor
Name',o.location,d.name as 'Department Name',c.title as 'Course
Name' from person p inner join officeassignment o on
p.personid=o.personid inner join courseinstructor ci on
o.personid=ci.personid inner join course c on
ci.courseid=c.courseid inner join department d on
c.departmentid=d.departmentid
48. WAQ to display studentname, deptname and enrollmentdate.
A:-a)select distinct(p.firstname+' '+p.lastname) as 'Student
Name',d.name as 'Department Name',p.enrollmentdate from department
d inner join course c on
-
d.departmentid=c.departmentid inner join enrollment e on
c.courseid=e.courseid inner join person p on
e.personid=p.personid
49. WAQ to display person detail whose descriminator='i'.
A:-select firstname,lastname,hiredate from person where
discriminator='i'
50. WAQ to display no. of courses available in maths dept. along
with deptname. A:-a)select count(courseid) as 'No.of Courses' from
department d inner join course c on d.departmentid=c.departmentid
where d.name='maths' b)select count(courseid) as 'No.of Courses'
from course where departmentid in (select departmentid from
department where name='maths')
51. WAQ to display deptname starting with 'ch'. A:-select name
as 'Department Name' from department where name like 'ch%'
52. WAQ to display depthead of maths. A:-a)select p.firstname+'
'+p.lastname as 'HOD' from department d inner join person p on
d.personid=p.personid where d.name='it'
-
b)select firstname+' '+lastname as 'HOD' from person where
personid in (select personid from department where name='it')
53. WAQ to display all dept head names with deptname. A:-select
d.name as 'Department Name',p.firstname+' '+p.lastname as 'HOD'
from department d inner join person p on d.personid=p.personid
54. WAQ to display dept.head names not starting with "s". A:-
select p.firstname+' '+p.lastname as 'HOD' from department d inner
join person p on d.personid=p.personid where firstname not like
's%'
55. WAQ to display no. of years exp. for "raj". A:-select
DATEDIFF(yy,hiredate,getdate()) as 'Experience' from person where
firstname='raj'
56. WAQ to count no. of students studying in university.
A:-select count(distinct personid) as 'No.of Students' from
enrollment
57. Waq to display empname and location? A:-select p.firstname+'
'+p.lastname as 'Employee Name',o.location from person p inner join
officeassignment o on p.personid=o.personid
-
58. waq to display student fullname and grade? A:-select
p.firstname as 'Student Name',sum(e.grade) as 'Total grades' from
enrollment e inner join person p on e.personid=p.personid group by
p.firstname
59. waq to create a view to display the employee details who are
working in CSE Department? A:- create view cseemp as select
distinct(p.firstname+' '+p.lastname) as 'Employee Name',p.hiredate
from department d inner join course c on
d.departmentid=c.departmentid inner join courseinstructor ci on
c.courseid=ci.courseid inner join person p on
ci.personid=p.personid where d.name='cse' select * from cseemp
60. waq to count the number of students that are available in
the univesrity? A:-select count(distinct personid) as 'No.of
Students' from enrolment
61. waq to count the number of students that are available in
each department ? A:-select d.name as 'Department
Name',count(distinct e.personid) as 'No.of Students' from
department d inner join course c on d.departmentid=c.departmentid
inner join enrollment e on c.courseid=e.courseid group by
d.name
-
62. waq to create a view to display instructor Details who are
working in CSE Department? A:- create view cseemp as select
distinct(p.firstname+' '+p.lastname) as 'Employee Name',p.hiredate
from department d inner join course c on
d.departmentid=c.departmentid inner join courseinstructor ci on
c.courseid=ci.courseid inner join person p on
ci.personid=p.personid where d.name='cse' select * from cseemp
63. waq to create a view to display instructor Details who are
working in Chemistry Department order by firstname? A:- create view
chemistryemp as select distinct(p.firstname+' '+p.lastname) as
'Employee Name',p.hiredate from department d inner join course c on
d.departmentid=c.departmentid inner join courseinstructor ci on
c.courseid=ci.courseid inner join person p on
ci.personid=p.personid where d.name='chemistry' select * from
chemistryemp
note:-we cannot apply order by clause in views 64. WAQ to create
a view to display student details? A:- create view studentdetails
as select distinct(p.firstname+' '+p.lastname) as 'Student
Name',d.name as 'Department Name',p.enrollmentdate from department
d inner join course c on
-
d.departmentid=c.departmentid inner join enrollment e on
c.courseid=e.courseid inner join person p on
e.personid=p.personid
65. Create a stored procedure to insert Records in person table?
A:- create procedure proc_addperson(@pid varchar(30),@lname
varchar(30),@fname varchar(30),@hdate date,@edate date,@disc
char(1)) as begin insert into person
values(@pid,@lname,@fname,@hdate,@edate,@disc) end exec
proc_addperson 'p10','kumar','anil','2014-8-1',null,'i'
66. Create a Stored procedure to delete kirankumar from person
table? A:- create procedure proc_delkiran as begin delete from
person where firstname='kiran' and lastname='kumar' end exec
proc_delkiran 67. Create a Stored procedure to update firstname
from sai to saiteja? A:- create procedure proc_updatesai as
begin
-
update person set firstname='saiteja' where firstname='sai' end
exec proc_updatesai 68. Create a Stored procedure to display
student firstname, lastname, Enrollmentdate? A:- create procedure
proc_displaysdetails as begin select
firstname,lastname,enrollmentdate from person where
discriminator='s' end exec proc_displaysdetails
69. Create a Stored procedure to display student firstname,
lastname, Enrollmentdate, Departmentname? A:- create procedure
proc_displaysdate as begin select distinct(p.firstname+'
'+p.lastname) as 'Student Name',d.name as 'Department
Name',p.enrollmentdate from department d inner join course c on
d.departmentid=c.departmentid inner join enrollment e on
c.courseid=e.courseid inner join person p on e.personid=p.personid
end exec proc_displaysdate
70. Create a Stored procedure to display courses that are
learning by ravi? A:- create procedure proc_70 as begin
-
select title as 'Courses' from course where courseid in (select
courseid from enrollment where personid in (select personid from
person where firstname='ravi')) end exec proc_70
71. Create a Stored procedure to display Department details
order by department name? A:- create procedure proc_deptdetails as
begin select * from department order by name end exec
proc_deptdetails
72. Create a Stored procedure to display the number of courses
that are available in each department? A:- create procedure proc_72
as begin select d.name as 'Department Name',count(c.courseid) as
'No.of Courses' from department d inner join course c on
d.departmentid=c.departmentid group by d.name end exec proc_72
-
73. Create a Stored procedure to Display the instructor names
who are teaching C, C++ and java? A:- create procedure proc_73 as
begin select distinct(p.firstname+' '+p.lastname) as 'Instructor
Name' from course c inner join courseinstructor ci on
c.courseid=ci.courseid inner join person p on
ci.personid=p.personid where c.title='C' or c.title='C++' or
c.title='JAVA' end exec proc_73
74. Create a Stored procedure to count the number of courses
learning by kiran? A:- create procedure proc_74 as begin select
count(courseid) as 'No.of Courses' from person p inner join
enrollment e on p.personid=e.personid where firstname='kiran' end
exec proc_74
75. Create a Stored procedure to display courses taught by
suresh? A:- create procedure proc_75 as begin select c.title as
'Course Names' from person p inner join courseinstructor ci on
p.personid=ci.personid inner join course c on
ci.courseid=c.courseid where firstname='suresh' end
-
exec proc_75
76. Create a Stored procedure to display student names that
enrolled for maths? A:- create procedure proc_76 as begin select
distinct(p.firstname+' '+p.lastname) as 'Student Name' from
department d inner join course c on d.departmentid=c.departmentid
inner join enrollment e on c.courseid=e.courseid inner join person
p on e.personid=p.personid where d.name='maths' end exec
proc_76
77. Write a TSQL Program to display fullname of p1? A:- declare
@pid varchar(30) begin set @pid='p1' select firstname+' '+lastname
as 'FULL NAME' from person where personid='p1' end select program
and press F5
78. Create a Trigger to display person details after inserting
the record in person table? A:- create trigger trig_78 on person
after insert as begin select * from person end
------------------------------------------------------------------------------
insert into person
values('p10','kumar','anil','2014-08-01',null,'i')
-
------------------------------------------------------------------------------
79. Create a Trigger to insert personid in officeAssignment
Table whenever any new instrutor is created? A:- create trigger
trig_79 on person after insert as begin declare @disc char(1),@pid
varchar(30) select @disc=discriminator,@pid=personid from inserted
if @disc='i' begin insert into officeassignment(personid)
values(@pid) end end
------------------------------------------------------------------------------------
insert into person
values('p10','kumar','anil','2014-08-01',null,'i')
------------------------------------------------------------------------------------
select * from officeassignment
80. Create a View To display Instructor details along with
Location and create a instead of trigger to insert the record in
both persontable and office assignment table? A:-
-
create trigger trig_80 on insdetails instead of insert as begin
declare @pid varchar(30),@fname varchar(30),@lname
varchar(30),@hdate date, @location varchar(50), @disc char(1)
select
@pid=personid,@fname=firstname,@lname=lastname,@hdate=hiredate,@location=location
from inserted set @disc='i' insert into person(personid, lastname,
firstname, hiredate, discriminator) values(@pid, @lname, @fname,
@hdate, @disc) insert into officeassignment values(@pid,@location)
end
------------------------------------------------------------------------------------
insert into insdetails
values('p11','kumar','sunil','2014-08-02','Pune')
------------------------------------------------------------------------------------
Person table
Office Assignment table
81. WAQ to display the person details along with rowid?
A:-select p.*,ROW_NUMBER() over(order by personid) as 'Rowid' from
person p
-
82. Create a stored procedure to display instructor details
along with location whose name starts with s? A:- create procedure
proc_82 as begin select p.firstname+' '+p.lastname as 'Instructor
Name',p.hiredate,o.location from person p inner join
officeassignment o on p.personid=o.personid where (p.firstname+'
'+p.lastname) like 's%' end exec proc_82
83. Create a Stored procedure to check whether login user is
valid or invalid? A:- create procedure proc_83(@uname
varchar(30),@pwd varchar(30)) as begin select * from users where
username=@uname and password=@pwd end exec proc_83 'anil','anilk'
84. Write a TSQL Program to update lastname based on Firstname? A:-
declare @lname varchar(30),@fname varchar(30) begin set
@lname='sharma' set @fname='kiran' update person set
lastname=@lname where firstname=@fname
-
end 85. Create a Stored Procedure to Count the number of courses
available in each department? A:- create procedure proc_noofcourses
as begin select d.name as 'Department Name',count(c.courseid) as
'No.of Courses' from department d inner join course c on
d.departmentid=c.departmentid group by d.name end exec
proc_noofcourses
86.Create a Table with name personbackup with columns opid,
olname, ofname, ohdate, oedate, oDescriminator, Npid, Nlname,
Nfname, Nhdate, Nedate, NDescriminator Create a Trigger to insert a
record in person table whenever we insert the record in person
table then automatically insert pid, lname, fname, hdate, edate,
descriminator in Npid, Nlname, Nfname, Nhdate, Nedate,
NDescriminator of personbackup and whenever user delete the record
in person table then automatically insert the deleted records in
opid, olname, ofname, ohdate, oedate, oDescriminator in person
Table? A:-create table personbackup(opid varchar(30), olname
varchar(30), ofname varchar(30) ,ohdate date, oedate date, odesc
char(1), npid varchar(30), nlname varchar(30), nfname varchar(30),
nhdate date, nedate date, onesc char(1)) Trigger create trigger
trig_personbkup on person after insert,delete as begin declare
@opid varchar(30), @olname varchar(30), @ofname varchar(30),
@ohdate date, @oedate date, @odisc char(1), @npid varchar(30),
@nlname varchar(30), @nfname varchar(30), @nhdate date, @nedate
date, @ndisc char(1) select @opid=personid, @olname=lastname,
@ofname=firstname, @ohdate=hiredate, @oedate=enrollmentdate,
@odisc=discriminator from deleted select @npid=personid,
@nlname=lastname, @nfname=firstname, @nhdate=hiredate,
@nedate=enrollmentdate, @ndisc=discriminator from inserted insert
into personbackup values(@opid, @olname, @ofname, @ohdate, @oedate,
@odisc, @npid, @nlname, @nfname, @nhdate, @nedate, @ndisc) end
-
insert into person
values('p10','kumar','sunil','2014-05-01',null,'i') Person
Table
insert into person
values('p10','kumar','sunil','2014-05-01',null,'i') Personbackup
table
87. Create a procedure to display the no of courses that are
available in each Department? A:- create procedure proc_noofcourses
as begin select d.name as 'Department Name',count(c.courseid) as
'No.of Courses' from department d inner join course c on
d.departmentid=c.departmentid group by d.name end exec
proc_noofcourses
-
88. Create a procedure to display The Course name and Department
name that are available in the university? A:- create procedure
proc_coursedept as begin select c.title as 'Course',d.name as
'Department' from department d inner join course c on
d.departmentid=c.departmentid end exec proc_coursedept
89. Create a stored procedure to display the coursename, Credits
and department name? A:- create procedure proc_89 as begin select
c.title as 'Course',c.credits,d.name as 'Department Name' from
department d inner join course c on d.departmentid=c.departmentid
end exec proc_89
90. Create a Procedure to display the Instructor Names who is
teaching c++. A:- create procedure proc_90 as begin
-
select p.firstname+' '+p.lastname as 'Instructor Name' from
course c inner join courseinstructor ci on c.courseid=ci.courseid
inner join person p on ci.personid=p.personid where c.title='c++'
end exec proc_90
91. Create a Stored Procedure to display studentname,
enrollmentdate, deptname order by studentname? A:- create procedure
proc_91 as begin select distinct(d.name) as 'Department
Name',p.firstname+' '+p.lastname as 'Student Name',p.enrollmentdate
from department d inner join course c on
d.departmentid=c.departmentid inner join enrollment e on
c.courseid=e.courseid inner join person p on e.personid=p.personid
order by p.firstname+' '+p.lastname end exec proc_91
92. Create a Stored Procedure to display the no of subjects
teaching by sai. A:- create procedure proc_92 as begin select
count(courseid) as 'No.of Courses' from person p inner join
courseinstructor ci on p.personid=ci.personid where
p.firstname='sai' end exec proc_92
93. Create a Stored Procedure to display the instructor names
who is teaching java? A:-
-
create procedure proc_93 as begin select p.firstname+'
'+p.lastname as 'Instructor Name' from course c inner join
courseinstructor ci on c.courseid=ci.courseid inner join person p
on ci.personid=p.personid where c.title='java' end
94. Create a Stored Procedure to display the instructor names
who is teaching Dotnet and whose name starts with r? A:- create
procedure proc_94 as begin select p.firstname+' '+p.lastname as
'Instructor Name' from course c inner join courseinstructor ci on
c.courseid=ci.courseid inner join person p on
ci.personid=p.personid where c.title='dotnet' and p.firstname like
'r%' end exec proc_94
95. Waq to create a clustered index on person Table? A:-create
clustered index ix_person_personid on person(personid) note:-We
cannot create more than one index on table. Whenever we are
applying primary key constraint on a cloumn in a table then
automatically clustered index will be applied on primary key column
96. Create a Procedure to count the number of students Enrolled for
C? A:- create procedure proc_countcstudents as begin select
count(distinct personid) as 'No.of Students' from course c inner
join enrollment e on c.courseid=e.courseid where c.title='c' end
exec proc_countcstudents
-
97. Can we call one stored procedure in another stored
procedure? A:-Yes 98. Waq to display all the Tablenames in UAS
Database? A:-select * from sys.tables
99. waq to display all the database names that are available in
your system? A:-select * from sys.databases
100. Create a Tsql Program to print a Message Best Of Luck? A:-
begin print 'Best of Luck' end select program and press F5