如何运行存储过程。用于插入值

时间:2014-08-01 07:39:33

标签: database

这是我的编码...... 如果我执行存储过程,这意味着在存储过程中 (通常选择所有内容,如果我按下菜单顶部的执行按钮) 这是工作 但 在一边 我该如何运行存储过程。 我试过这样的 exec uspGetAddress' CDB0001',' Bevcon Wayors Pvt Ltd',' c' 但没有工作。

SET NOCOUNT ON 
DECLARE @Cuscode varchar(250)
DECLARE @customertName VARCHAR(250) 
DECLARE @custype varchar(250)

DECLARE @Cur_Product CURSOR 
set @Cur_Product= cursor for select CardCode,CardName,CardType  from ocrd 

open @Cur_Product
       fetch next
       from @Cur_Product into @Cuscode,@customertName,@custype
       while @@FETCH_STATUS = 0
       begin
       insert into custupdate (ccode,cname,ctype) values (@Cuscode,@customertName,@custype)
       fetch next 
       from @Cur_Product into @Cuscode,@customertName,@custype
       end 
       close @Cur_Product
       deallocate @Cur_Product

1 个答案:

答案 0 :(得分:0)

您必须在调用之前创建存储过程:

Create Procedure uspGetAddress 
 @Cuscode varchar(250),
 @customertName VARCHAR(250) ,
 @custype varchar(250)
As
Begin

DECLARE @Cur_Product CURSOR 
set @Cur_Product= cursor for select CardCode,CardName,CardType  from ocrd 

open @Cur_Product
       fetch next
       from @Cur_Product into @Cuscode,@customertName,@custype
       while @@FETCH_STATUS = 0
       begin
       insert into custupdate (ccode,cname,ctype) values (@Cuscode,@customertName,@custype)
       fetch next 
       from @Cur_Product into @Cuscode,@customertName,@custype
       end 
       close @Cur_Product
       deallocate @Cur_Product
End