?? 課堂示范.txt
字號:
-----1.用戶自定義的標量函數的應用
Create Function tiji(@CubeLength decimal(4,1),@CubeWidth decimal(4,1),
@CubeHeight decimal(4,1))
Returns decimal(12,3)
As
Begin
Return (@CubeLength*@CubeWidth*@CubeHeight)
End
----------------------------------------------------------------------------------------------------------------------
-----標量函數應用1
Select dbo.CubicVolume(100,100,100)
----------------------------------------------------------------------------------------------------------------------
-----標量函數應用2
Create Table Bricks
(
BrickPartNumber int primary key,
BrickColor varchar(20),
BrickHeight decimal(4,1),
BrickLength decimal(4,1),
BrickWidth decimal(4,1),
BrickVolume As (dbo.CubicVolume(BrickLength,BrickWidth,BrickHeight))
)
----------------------------------------------------------------------------------------------------------------------
insert into Bricks(BrickPartNumber,BrickColor,BrickHeight,BrickLength,BrickWidth)
values(1,120,12,12,12)
----------------------------------------------------------------------------------------------------------------------
Select * from Bricks
----------------------------------------------------------------------------------------------------------------------
----2.用戶自定義內嵌表值函數
Use pubs
go
Create Function SalesByStore(@storeid varchar(30))
Returns TABLE
As
Return(Select title,qty
From sales s,titles t
Where s.stor_id=@storeid and t.title_id=s.title_id
)
----------------------------------------------------------------------------------------------------------------------
----內嵌表值函數的應用
Select * from SalesByStore('7066')
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -