惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Help Net Security
博客园 - Franky
GbyAI
GbyAI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
爱范儿
爱范儿
IT之家
IT之家
酷 壳 – CoolShell
酷 壳 – CoolShell
aimingoo的专栏
aimingoo的专栏
博客园_首页
MongoDB | Blog
MongoDB | Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recent Announcements
Recent Announcements
Scott Helme
Scott Helme
有赞技术团队
有赞技术团队
M
MIT News - Artificial intelligence
C
CERT Recently Published Vulnerability Notes
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Jina AI
Jina AI
F
Fortinet All Blogs
N
Netflix TechBlog - Medium
L
LangChain Blog
L
LINUX DO - 最新话题
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
H
Hacker News: Front Page
MyScale Blog
MyScale Blog
P
Palo Alto Networks Blog
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
AI
AI
T
Troy Hunt's Blog
Microsoft Azure Blog
Microsoft Azure Blog
阮一峰的网络日志
阮一峰的网络日志
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Vercel News
Vercel News
Microsoft Security Blog
Microsoft Security Blog
罗磊的独立博客
S
Secure Thoughts
大猫的无限游戏
大猫的无限游戏
博客园 - 叶小钗
人人都是产品经理
人人都是产品经理
Blog — PlanetScale
Blog — PlanetScale
博客园 - 司徒正美
Apple Machine Learning Research
Apple Machine Learning Research
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
S
Security @ Cisco Blogs
Cloudbric
Cloudbric
E
Exploit-DB.com RSS Feed
Attack and Defense Labs
Attack and Defense Labs

博客园 - shipfi

CMarkup的改进 - shipfi - 博客园 asp.net中的AJAX编程-异步网络调用 asp.net中的AJAX编程-Ajax服务器扩展 asp.net中的AJAX编程-Javascript语法补充 asp.net中的AJAX编程-ASP.NET AJAX框架 asp.net问题点集合 asp.net学习之ado.net(无连接模式中的DataAdapter) asp.net学习之ado.net(连接模式访问) asp.net学习之DataList控件 asp.net学习之Repeater控件 asp.net学习之扩展GridView asp.net学习之GridView事件、GridViewRow对象 asp.net学习之GridView七种字段 asp.net学习之GridView asp.net学习之再论sqlDataSource asp.net学习之SqlDataSource asp.net学习之 数据绑定控件--表格绑定控件 asp.net学习之 数据绑定控件--List数据绑定控件 asp.net学习之数据绑定控件、数据源控件概述
理解T-SQL: 存储过程 - shipfi - 博客园
shipfi · 2009-10-14 · via 博客园 - shipfi

   存储过程的定义、描述就不多说了,都明白。直接从基本的存储过和开始讲起。

1. 创建存储过程

CREATE { PROC | PROCEDURE } [schema_name.] procedure_name [ ; number ]
    
[ { @parameter [ type_schema_name. ] data_type }
        
[ VARYING ] [ = default ] [ [ OUT [ PUT ]
    ] 
[ ,]
[ WITH <procedure_option> [ ,]   --procedure_option可以有RECOMPILE、ENCRYPTION等。
[ FOR REPLICATION ]
AS
     { 
<sql_statement> [;][ ] | <method_specifier> }      [;]
        
<sql_statement> ::=   { [ BEGIN ] statements [ END ] }
        
<method_specifier> ::= EXTERNAL NAME assembly_name.class_name.method_name

   以上,重要的,procedure_name表示存储过程名,注意不要使用sp_开头的名称,因为容易与系统存储过程混淆。
   @parameter表示参数,可以有多个,data_type,表示参数的类型,另外,支持默认参数,只要在参数后面加上"=defaultvalue"即可。
   如果想要输出参数,则需要加OUTPUT关键字,
   参数定义好后,就开始到正式存储过程的代码了,使用AS表示存储过程代码开始。
   sql_statement表示代码正文,以begin..end包括起来。

      1.1 一个简单的存储过程 

Create Procedure prGetEquipment
    
@chvMake varchar(50)
as
    
Select * from Equipment where Make = @chvMake

      1.2 判断存储过程存不存在

   if exists (select * from sysobjects where id = object_id('prGetEquipment ')
               
and OBJECTPROPERTY(id, 'IsProcedure'= 1)
        
drop procedure prGetEquipment

注:暂时先把这篇给贴上去,以后在项目中用到存储过程时,会把相应的代码和注释贴上来,存储过程一节纯粹是在项目中学习。