Scripts
Scripts
PAGE 1
use master
use abisanka
create database sarkar
update abi
set address='calcutta'
where uid='001'
2. PAGE 2
/*CREATE TABLE*/
/*LIKE*/
/*BETWEEN*/
select studentfees from student where studentfees between 5000 and 7000
/*NOT IN*/
/*IN*/
/*CREATE TABLE*/
/*PROCEDURE*/
/*insert*/
create procedure sp_insertadmin
@sclass int
as insert into admin values(@sclass)
Go
exec sp_insertadmin 10
exec sp_insertadmin 08
exec sp_insertadmin 06
exec sp_insertadmin 11
exec sp_insertadmin 12
exec sp_insertadmin 19
exec sp_insertadmin 10
/*create*/
exec sp_copy
/*insert*/
create procedure sp_inserttbl
@age int,
@salary int
as insert into tbl values(@age,@salary)
Go
/*delete*/
exec sp_deletetbl 20
/*update*/
/*alter*/
exec sp_altertbl
/*JOIN*/
/*PROCEDURE*/
exec sp_alld 1
sp_helpdb
sp_helpdb abisanka
--go
3. PAGE 3
use abisanka
select dateadd(mm,11,getdate())
select dateadd(hh,11,getdate())
select dateadd(yy,100,getdate())
set datefirst 1
/*Answers*/
select datepart(month,getdate())
update icra1
set ids=6
where names='c'
select square(4)
select sqrt(4)
select dbo.f(5)
select dbo.i7('jahgjh','kjhkj')
4. PAGE 4
use abisanka
/*CURSOR*/
sp_helpdb abisanka
5. PAGE 5
exec sp_stored_procedures
6. ASSIGNMENT
--CREATE
--INSERT
--ANSWERS
-- 3.
--4.
--5.
from t_artist p,
t_song q,
t_genre r,
t_album s,
t_artist_song t
where p.artist_id=t.artist_id
and q.song_id=t.song_id
and q.gen_id=r.gen_id
and q.album_id=s.album_id
and s.album_name=@album
go
--6.
--Begin
else
--End
GO
--7.
--8.
End
If (not exists(select artist_name from t_artist where artist_name=@artist_name))
Begin
SELECT @@CPU_BUSY
SELECT @@IDLE
7. ASSIGNMENT 2
values('S00002','Manish','65','Nariman','Bombay','400001','Maharastra',3000,200,100,'Good')
insert into Salesman_master
values('S00003','Ravi','P-7','Bandra','Bombay','400032','Maharastra',3000,200,100,'Good')
insert into Salesman_master
values('S00004','Ashish','A/5','Juhu','Bombay','400044','Maharastra',3500,200,150,'Good')
Process')
--b)
select Name from client_master
where (City like '_a%')
--c)
select Name from client_master
where City like 'Delhi' or City like 'Bombay'
--d)
select Name from Client_master
where (Bal_due > 10000)
--e)
select *from Sales_order
where convert(varchar(10),Month(Order_date),100)=1
--f)
select *from Sales_order
where Sales_order.Client_no = 'C00001'
or Sales_order.Client_no='C00002'
--g)
select description from Product_master
where Sell_price>2000 and Sell_price<=5000
--h)
select sell_price as Old_price, Sell_price *.15 as New_Price from Product_master
--i)
select Name,City,State from Client_master
where State not in ('Maharashtra')
--j)
select count(Qty_on_hand) as Total_order from Product_master
select sum(Qty_on_hand) as Total_order from Product_master
--j)
select count(Order_no) from Sales_order_details
--k)
select avg(Sell_price) as Avg_Sell_Price,avg(Cost_price) as Avg_Cost_price
from Product_master
--m)
select count(product_no)from Sales_order_details
where Product_rate >=1500
--n)
select * from Product_master
where Qty_on_hand < Reorder_lvl
--4(a)
select order_no,convert(varchar(20),order_date,109) from sales_order
--4(b)
--4(c)
--4(d)
select dateadd(dd,15,getdate())
--4(e)
--5(a)
p.product_no=s.product_no
group by p.description
--5(b)
select p.description,sum(s.qty_disp * s.product_rate) from Product_master p left outer join
sales_order_details s on p.product_no=s.product_no
group by p.description
--5(c)
--5(d)
--6(a)
so,sales_order s
where s.client_no =c.client_no and s.order_no=so.order_no and so.product_no=p.product_no and
c.name='Ivan Bayross'
--6(b)
--6(c)
--6(d)
--6(e)
--6(f)
--6(g)
--7(a)
select product_no,description from product_master
where qty_on_hand=(select max(qty_on_hand) from product_master)
--7(b)
--7(c)
--7(d)
so
where c.client_no=s.client_no
and s.order_no=so.order_no
and so.product_no=p.product_no
and p.description='1.44 Drive'
--7(e)
s,sales_order_details so
where so.order_no=s.order_no
and s.client_no=c.client_no
group by c.name
having sum(so.qty_ordered*so.product_rate)>=10000
--8(a)
--8(b)
select (p.description) + ' ' + 'Worth Rs.'+' '+
(Convert(varchar(15),sum(s.qty_disp*s.Product_rate)))+'
--8(C)
select (c.name) + ' ' + 'has placed order'+' '+ (s.order_no)+' '+ 'on'+'
'+(convert(varchar(11),s.order_date)) as Result
from client_master c,sales_order s
where c.client_no=s.client_no