———- sysobjects tablosundaki xtype açıklamaları
/*** XTYPE
C = CHECK constraint
D = Default or DEFAULT constraint
F = FOREIGN KEY constraint
L = Log
FN = Scalar function
IF = In-lined table-function
P = Stored procedure
PK = PRIMARY KEY constraint (type is K)
RF = Replication filter stored procedure
S = System table
TF = Table function
TR = Trigger
U = User table
UQ = UNIQUE constraint (type is K)
V = View
X = Extended stored procedure
****/
——- sysobjects içindeki type tanımlamaları ————-
/**** TYPE
C = CHECK constraint
D = Default or DEFAULT constraint
F = FOREIGN KEY constraint
FN = Scalar function
IF = In-lined table-function
K = PRIMARY KEY or UNIQUE constraint
L = Log
P = Stored procedure
R = Rule
RF = Replication filter stored procedure
S = System table
TF = Table function
TR = Trigger
U = User table
V = View
X = Extended stored procedure
**********/
exec usp_ListCustomers
go
execute usp_ListCustomers
go
usp_ListCustomers
go
alter procedure usp_ListCustomers
as
select CustomerID,CompanyName from customers
where Country = ‘UK’
go
drop procedure usp_ListCustomers
select * from [order details]
–declare @pid int
–set @pid = 111
alter proc usp_GetTotalbyProductID
@pid int
as
IF EXISTS (select productID from [order details] where ProductID = @pid)
begin
select SUM(Unitprice * Quantity) as ‘Total’
from [order details]
where ProductID = @pid
end
ELSE
raiserror(‘Unmatched ProductID…’,14,1)
return
GO
exec usp_GetTotalbyProductID 11
select top 2 * from [order details]
select * from orders
select top 2 * from customers
select top 2 * from products
declare @startdate datetime , @enddate datetime
set @startdate = ‘19960701 00:00:00′
set @enddate = ‘19960801 00:00:00′
create procedure usp_GetTotalReport
@startdate datetime ,
@enddate datetime
as
select p.productname , sum(od.unitprice * od.quantity) as total
from [order details] od inner join orders o
on o.orderID = od.OrderID
inner join products p
on p.productID = od.productID
where o.orderdate between @startdate and @enddate
group by p.productname
order by p.productname
GO
usp_GetTotalReport ‘19960701 00:00:00′,’19960801 00:00:00′
create proc topla2
@sayi1 int,
@sayi2 int,
@sonuc int output
with recompile
as
select @sonuc = @sayi1 + @sayi2
GO
declare @sonuc int
EXEC topla 1,2,@sonuc output
select @sonuc
sp_recompile topla
declare @startdate datetime , @enddate datetime
set @startdate = ‘19960101 00:00:00′
set @enddate = ‘20060801 00:00:00′
alter proc usp_deleteproduct
@pid int
as
delete from products where productID = @pid
if @@rowcount = 0
begin
print ‘Hata oluştu…’
return 99
end
else
print ‘Product that has the number’ + cast(@pid as varchar(10)) + ‘was deletede successfully’
return 0
go
usp_deleteproduct 11
sysobjects tablosundaki xtype açıklamaları
Hiç yorum yok:
Yorum Gönder