-
Notifications
You must be signed in to change notification settings - Fork 0
/
shoppingmall_SP.sql
53 lines (35 loc) · 1.1 KB
/
shoppingmall_SP.sql
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
use ShoppingMall
------------Stored procedure(SP)--- '
Create Procedure sp_GetCustomerList --You can created procedure
as
Begin
select FirstName+SPACE()+ LastName as [fullname]
from Customers
end;
execute sp_GetCustomerList
create procedure sp_urunbycategory @id int --Ýf you need parameter , you should write type
as
begin
select ProductName,
CategoryName
from Categories C
join Products P on c.ID=p.CategoryID
where c.ID=@id
end
execute sp_urunbycategory @id=8
create procedure sp_Fullname @name nVarchar(50), @surname nVarchar(50)
as
begin
select FirstName, LastName from Customers
where FirstName= @name and Lastname=@surname
end
execute sp_Fullname @name='Matt' ,@surname= 'Kev '
-- execute sp_Fullname 'Matt' ,'Kev'
ALTER procedure sp_Fullname @name nVarchar(50), @surname nVarchar(50) --updated
as
begin
select FirstName, LastName, Phone from Customers
where FirstName= @name and Lastname=@surname
end
execute sp_Fullname @name='Matt' ,@surname= 'Kev '
--