-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathclass4.sql
More file actions
97 lines (69 loc) · 2.37 KB
/
class4.sql
File metadata and controls
97 lines (69 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
create table booking
(
bookid int ,
bookdate date,
noofpt int,
constraint pk_booking primary key(bookid,bookdate)
)
create table bookstatus
(
bookst bit,
bookid int,
bookdate date,
--foreign key(bookid,bookdate) references booking(bookid,bookdate)
)
drop table booking
alter table bookstatus add constraint fk_bookstatus foreign key(bookid,bookdate) references booking(bookid,bookdate)
drop table bookstatus
alter table booking alter column bookid int not null
alter table booking alter column bookdate date not null
alter table booking add constraint pk_booking primary key(bookid,bookdate)
alter table bookstatus drop constraint fk_bookstatus
alter table booking drop constraint PK_booking_C33FEC8B7226EDCC
alter table booking drop column noofpt
alter table booking add noofpt int
select * from booking
insert into booking values(1,'2021-08-17',500)
create table orderdetails
(
orderid int,
dtoford date,
itm nvarchar(20),
sellingprice float
)
select SUM(sellingprice) from orderdetails where dtoford>='2021-07-01' and dtoford<='2021-07-31'
drop table orderdetails
insert into orderdetails values(4,'2021-08-16','item5')
select top 20 percent * from orderdetails order by orderid desc
select count(*) from orderdetails
select * from student
select count(address) from student where address='dinajpur'
insert into student values(7,'diamond','Dinajpur')
select * from student where address like '[a-f]%'
select regno as 'Registration No' , name as 'Name', address as 'ADD' from student
create table marks
(
examst nvarchar(10),
regno int,
)
insert into marks values('pass',3)
select * from student
select * from marks
select regno,name,address from student where regno in(select regno from marks where examst='fail')
select s.regno, s.name,s.address, m.examst from student s , marks m where s.regno=m.regno and m.examst='fail'
select student.regno, student.name,student.address,marks.examst from student right join marks on student.regno=marks.regno
alter proc proc1
as
begin
select regno,name,address from student where regno in(select regno from marks where examst='fail')
end
drop proc proc1
exec proc1
insert into student values(9,'xyz','kolkata')
create proc procstudata @regno int, @name nvarchar(50), @address nvarchar(100)
as
begin
insert into student(regno,name,address) values(@regno,@name,@address)
end
exec procstudata 11,'kkkk','malda'
select * from student