当前位置: 代码迷 >> Sql Server >> 将ORACLE的一个存储过程转向SQLSERVER
  详细解决方案

将ORACLE的一个存储过程转向SQLSERVER

热度:82   发布时间:2016-04-24 09:25:39.0
将ORACLE的一个存储过程转为SQLSERVER
定义了名为test_yg的存储过程,该存储过程只实现了记录的新增、修改,用户根据自己的业务情况扩充其它功能。
存储过程第一个参数必须为返回值且为类型游标,但实际不用返回游标。其它参数根据需要定义所需要的传入参数,这里定义了p_yg_bh、p_mc、p_xb、p_dhhm四个传入的参数,分别接收“员工编码”,“员工姓名”,“员工性别”,“电话号码”信息。

create or replace procedure test_yg(r_cur out sys_refcursor,p_yg_bh in number,p_mc in varchar2,p_xb in number,p_dhhm in varchar2)
is
d_id number;
begin

if p_yg_bh is null then  --判断传入的yg_bh为空
  if p_mc is not null then
    select decode(max(yg_bh),null,1,max(yg_bh)+1) into d_id from t_yg;
    insert into t_yg(yg_bh,mc,xb,dhhm) values(d_id,p_mc,op_xb,p_dhhm);  --新增
  end if;
else--判断传入的yg_bh不为空
   if p_mc is not null then
      update t_yg set mc=p_mc,xb=p_xb,dhhm=p_dhhm where yg_bh=p_yg_bh;  --修改
 end if;

end test_yg; 


求教如何将上述转为sqlserver的存储过程??主要是这个游标定义为输出,具体该怎么用不明了。
------解决思路----------------------
sys_refcursor
MSSQL SERVER 貌似没有对应的,你要闹哪样呢
  相关解决方案