当前位置:网站首页>Bi-sql stored procedure (I)
Bi-sql stored procedure (I)
2022-06-25 23:33:00 【Powerbi white tea】

stored procedure ( One )
stored procedure , Can be said to be SQL The more important concept in , Basically, all data projects will involve this content .
Many interviews take place in the second round of technical interviews , It will also be mentioned , So what are stored procedures ?
Definition
Stored procedures are similar to C Functions in language
It can usually be used to perform administrative tasks or apply complex rules
Stored procedures can take parameters , You can also return the result directly
Stored procedures can contain data manipulation statements 、 Variable 、 Logic control statements, etc
White tea recently talked about stored procedures with her development partners , That's what he said :
stored procedure , You can think of it as a data set .
Can be called by an internal trigger , Can be called by external programs , It can also be called by other stored procedures .
grammar
SQL Server grammar :
CREATE PROCEDURE Stored procedure name
@PARAMETER Parameter type
......
AS
BEGIN
Procedure statement
END
Call stored procedure statement :
EXECUTE Process name
Using examples
Case data :



In the database of white tea machine, there is a database named “CaseData” The database of .
“Dim_Date“ Date sheet 、"Dim_Product" Product list 、"Fact_Sales" Sales fact sheet .
Example 1:
Create a TEST1 Stored procedure , The product name in the filtered products table is “ sunglasses ” The data of .
CREATE PROCEDURE TEST1
AS
BEGIN
SELECT * FROM Dim_Product WHERE ProductName=' sunglasses '
END
give the result as follows :

Let's try calling this stored procedure to see the result :
EXECUTE TEST1
give the result as follows :

Example 2:
Create a TEST2 Stored procedure , Store all data in the product table , And add parameters , So that subsequent conditional calls can be made .
CREATE PROCEDURE TEST2
@Product VARCHAR(20)
AS
BEGIN
SELECT * FROM Dim_Product WHERE [email protected]
END
give the result as follows :

The input name is “ masks ‘ Conditions , Let's call TEST2 stored procedure .

In terms of results , In line with our expectations .

actually , Stored procedures have a lot more , White tea is not introduced in detail , For example, what are the benefits of stored procedures , For example, the use of stored procedures to add loops , The usage of adding cursors to stored procedures, etc .
Later, white tea will be added slowly , There are some inaccuracies in the article , Please forgive me , White tea is also in the stage of just learning .
Take dreams as horses , Not to lose time , May we learn together , Common progress .


This is white tea , One PowerBI Beginners .
边栏推荐
猜你喜欢

【AXI】解读AXI协议原子化访问

How to add cartoon characters to the blog park?

konva系列教程2:绘制图形

Several optimization scenarios using like fuzzy retrieval in SQL

When are the three tools used for interface testing?

Repoptimizer: it's actually repvgg2

【无标题】打开一个项目连接,无法正常显示时,ping一下ip

Sword finger offer 46 Translate numbers to strings (DP)

Live800在线客服系统:跨越时空做生意,从每次互动开始
Why is BeanUtils not recommended?
随机推荐
【2023校招刷题】番外篇1:度量科技FPGA岗(大致解析版)
Live800 online customer service system: do business across time and space, starting from each interaction
Comp212 distributed protocol
QLabel 文字水平滚动显示
To solve the incompatibility between VM and device/credential guard, an effective solution for the whole network
解决TypeError: Unicode-objects must be encoded before hashing
Pycharm student's qualification expires, prompting no suitable licenses associated with account solution
Use and difference between ue4\ue5 blueprint node delay and retroggable delay
Why is BeanUtils not recommended?
23class introduction
软件测试面试一直挂,面试官总是说逻辑思维混乱,怎么办?
Visual studio code create minimal web API (asp.net core)
Fegin client entry test
[opencv450 samples] create image list yaml
信息学奥赛一本通 1353:表达式括号匹配(stack) | 洛谷 P1739 表达式括号匹配
Comp2913 database
When are the three tools used for interface testing?
Set up your own website (15)
ACM. Hj16 shopping list ●●
konva系列教程2:绘制图形