最近在做vb項(xiàng)目的時(shí)候,用到了存儲(chǔ)過程的調(diào)試,現(xiàn)在總結(jié)一下發(fā)現(xiàn)單步調(diào)試存儲(chǔ)過程有以下2種方法:

10年積累的成都做網(wǎng)站、成都網(wǎng)站設(shè)計(jì)、成都外貿(mào)網(wǎng)站建設(shè)經(jīng)驗(yàn),可以快速應(yīng)對(duì)客戶對(duì)網(wǎng)站的新想法和需求。提供各種問題對(duì)應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認(rèn)識(shí)你,你也不認(rèn)識(shí)我。但先網(wǎng)站制作后付款的網(wǎng)站建設(shè)流程,更有欒川免費(fèi)網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。
1.這種方法自己已經(jīng)做過,是可以的,如下:
a.如果目標(biāo)數(shù)據(jù)庫存在存儲(chǔ)過程,右擊該存儲(chǔ)過程-修改,打開存儲(chǔ)過程,并在需要的地方設(shè)置斷點(diǎn)。(如果沒有自定義存儲(chǔ)過程,則需要在Sql Server 2012數(shù)據(jù)庫中創(chuàng)建存儲(chǔ)過程,完成后在里面設(shè)置斷點(diǎn));
b.另外開啟一個(gè)新建查詢窗口,寫入調(diào)用代碼:例如???exec?BillManageInputProc?'主單1','0111111','0111112','121','legend','2014-09-24','001','2014-09-24','1','市場部','0' ,單擊 調(diào)試按鈕 啟動(dòng)存儲(chǔ)過程的調(diào)試;
c.單擊?F?11?進(jìn)行逐句調(diào)試。
2.在vs2010調(diào)試存儲(chǔ)過程步驟如下:
首先,打開vs,點(diǎn)擊 視圖--服務(wù)器資源管理器
代碼是最好的文字,不多說,請看我的代碼,并給分,呵呵。
--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.建存儲(chǔ)過程
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
--如果希望大小寫敏感,使用第一句,因?yàn)镾QL Server默認(rèn)是大小寫不敏感的
--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
--測試數(shù)據(jù)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
--測試數(shù)據(jù)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
如何創(chuàng)建存儲(chǔ)過程
在對(duì)象資源管理器中,連接到某個(gè)數(shù)據(jù)庫引擎實(shí)例,再展開該實(shí)例。
展開“數(shù)據(jù)庫”、存儲(chǔ)過程所屬的數(shù)據(jù)庫以及“可編程性”。
右鍵單擊“存儲(chǔ)過程”,再單擊“新建存儲(chǔ)過程”。
在“查詢”菜單上,單擊“指定模板參數(shù)的值”。
在“指定模板參數(shù)的值”對(duì)話框中,“值”列包含參數(shù)的建議值。接受這些值或?qū)⑵涮鎿Q為新值,再單擊“確定”。
在查詢編輯器中,使用過程語句替換 SELECT 語句。
若要測試語法,請?jiān)凇安樵儭辈藛紊希瑔螕簟胺治觥薄?/p>
若要?jiǎng)?chuàng)建存儲(chǔ)過程,請?jiān)凇安樵儭辈藛紊希瑔螕簟皥?zhí)行”。
若要保存腳本,請?jiān)凇拔募辈藛紊希瑔螕簟氨4妗薄=邮茉撐募驅(qū)⑵涮鎿Q為新的名稱,再單擊“保存”。
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
create proc test ------創(chuàng)建存儲(chǔ)過程 test
@a int =‘’-----------創(chuàng)建變數(shù) 有的存儲(chǔ)過程不需要變數(shù),這個(gè)看個(gè)人所需要
as ---------------執(zhí)行以下語句
select * from table where a=@a -------------------後面寫自己需要的語句
go
--------exec test ‘1’----------執(zhí)行存儲(chǔ)過程
新聞標(biāo)題:sqlserver存儲(chǔ)過程教程,sqlserver 儲(chǔ)存過程
文章網(wǎng)址:http://chinadenli.net/article25/dsgsjci.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站建設(shè)、動(dòng)態(tài)網(wǎng)站、ChatGPT、外貿(mào)網(wǎng)站建設(shè)、營銷型網(wǎng)站建設(shè)、微信公眾號(hào)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)