资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

sqlserver存储过程教程,sqlserver 储存过程

sqlserver存储过程怎么调试

最近在做vb项目的时候,用到了存储过程的调试,现在总结一下发现单步调试存储过程有以下2种方法:

10年积累的成都做网站、成都网站设计、成都外贸网站建设经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先网站制作后付款的网站建设流程,更有栾川免费网站建设让你可以放心的选择与我们合作。

1.这种方法自己已经做过,是可以的,如下:

a.如果目标数据库存在存储过程,右击该存储过程-修改,打开存储过程,并在需要的地方设置断点。(如果没有自定义存储过程,则需要在Sql Server 2012数据库中创建存储过程,完成后在里面设置断点);

b.另外开启一个新建查询窗口,写入调用代码:例如   exec BillManageInputProc '主单1','0111111','0111112','121','legend','2014-09-24','001','2014-09-24','1','市场部','0' ,单击 调试按钮 启动存储过程的调试;

c.单击 F 11 进行逐句调试。

2.在vs2010调试存储过程步骤如下:

首先,打开vs,点击 视图--服务器资源管理器

编写一个SQLSERVER 存储过程

代码是最好的文字,不多说,请看我的代码,并给分,呵呵。

--step1. 建表

if exists(select * from sysobjects where id=object_id('student') and objectproperty(id,'IsTable')=1)

drop table student

go

create table student

(

id int identity(100,10) not null

,sname varchar(10) not null

,sno varchar(30) not null

)

go

--step2.建存储过程

if exists(select * from sysobjects where id=object_id('proc_demo') and objectproperty(id,'IsProcedure')=1)

drop procedure proc_demo

go

create procedure proc_demo

@o_maxid int output

as

set nocount on

--如果希望大小写敏感,使用第一句,因为SQL Server默认是大小写不敏感的

--update student set sno='cay_'+sno where ascii(substring(sname,1,1))=87 and ascii(substring(sname,2,1))=65 and sno not like 'cay_%'

update student set sno='cay_'+sno where sname like 'WA%' and sno not like 'cay_%'

print convert(varchar(10),@@rowcount)+'条记录符合条件并被处理'

select @o_maxid=max(id) from student where id=100

if(@o_maxid is null) print '没有找到符合条件的最大记录'

set nocount off

go

--测试数据1

truncate table student

set identity_insert student on

insert into student(id,sname,sno)values(1,'WA1','1');

insert into student(id,sname,sno)values(2,'wa2','2');

insert into student(id,sname,sno)values(3,'3','3');

set identity_insert student off

go

--测试数据2

truncate table student

insert into student(sname,sno)values('WA1','1');

insert into student(sname,sno)values('wa2','2');

insert into student(sname,sno)values('3','3');

go

--测试过程

declare @maxid int

exec proc_demo @maxid out

print '最大id是'+convert(varchar(10),@maxid)

go

sqlserver怎么创建存储过程

如何创建存储过程

在对象资源管理器中,连接到某个数据库引擎实例,再展开该实例。

展开“数据库”、存储过程所属的数据库以及“可编程性”。

右键单击“存储过程”,再单击“新建存储过程”。

在“查询”菜单上,单击“指定模板参数的值”。

在“指定模板参数的值”对话框中,“值”列包含参数的建议值。接受这些值或将其替换为新值,再单击“确定”。

在查询编辑器中,使用过程语句替换 SELECT 语句。

若要测试语法,请在“查询”菜单上,单击“分析”。

若要创建存储过程,请在“查询”菜单上,单击“执行”。

若要保存脚本,请在“文件”菜单上,单击“保存”。接受该文件名或将其替换为新的名称,再单击“保存”。

SqlServer存储过程

create

procedure

prCreateSubPlan

as

begin

declare

@id

int,

@intCycle

int,

@planName

varchar(100),

@createTime

smalldatetime,

@cycleTime

int

select

@id

=

min(t_cplan_id)

from

t_cplan

while

(@id

is

not

null)

begin

select

@planName=t_plan_name,

@createTime

=

createTime,

@cycleTime

=

cycleTime

from

t_cplan

where

t_cplan_id=@id

select

@intCycle=

while

(@intCycle@cycleTime)

begin

--

表t_plan

列t_plan_id是IDENTITY

insert

t_plan

(t_plan_name,

t_cplan_id,

createTime)

values

(@planName,

@id,

dateadd(day,

@intCycle,

@createTime))

select

@intCycle

=

@intCycle

+

1

end

select

@id

=

min(t_cplan_id)

from

t_cplan

where

t_cplan_id@id

end

end

go

sqlserver如何写存储过程

create proc test ------创建存储过程 test

@a int =‘’-----------创建变数 有的存储过程不需要变数,这个看个人所需要

as ---------------执行以下语句

select * from table where a=@a -------------------後面写自己需要的语句

go

--------exec test ‘1’----------执行存储过程


新闻标题:sqlserver存储过程教程,sqlserver 储存过程
网站网址:http://cdkjz.cn/article/dsgsjci.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220