• 技术文章 >后端开发 >php教程

    调用使用链接服务器的mssql存储过程遇到的有关问题

    2016-06-13 11:18:38原创315
    调用使用链接服务器的mssql存储过程遇到的问题
    本帖最后由 ycliaojy 于 2013-03-24 20:40:29 编辑

      php调用使用链接服务器的mssql存储过程出错,哪位有遇过到类似的问题?
      //省略其它语句
      $queryP= "exec OA_pfm_attend_group_toExempt @begin='$DATE1',@end='$DATE2'";
      $cursor = msexequery( $msconnection, $queryP );
      //省略其它语句
      //组合的$queryP是:exec OA_pfm_attend_group_toExempt @begin='2013-03-01',@end='2013-03-24'
      存储过程在查询分析器执行没有问题,把所有使用链接服务器的语句删除后php调用也没有问题,是不是php调用的存储过程不能使用链接服务器?我写个asp试试有问题没[经过测试,存储过程在asp下执行也没有任何问]

      php的出错信息无参考价值:
      错误#0:
      SQL语句: exec OA_pfm_attend_group_toExempt @begin='2013-03-01',@end='2013-03-24'
      sqlserver事件跟踪和日志信息查不到有用的信息.

    存储过程代码:

    drop proc OA_pfm_attend_group_toExempt
    go
    Create proc OA_pfm_attend_group_toExempt
    @begin datetime,
    @end datetime
    as
    begin
    set nocount on
    set ANSI_WARNINGS on
    set ANSI_NULLS on
    --declare @begin datetime
    --declare @end datetime
    --set @begin = @beginSTR
    --set @end = @endSTR
    create table #query_Table_Temp (
    checkDay datetime not null
    ,checkIn datetime not null
    ,checkOut datetime not null
    ,isHoliday bit not null default 0
    )
    declare @checkDay datetime
    declare @checkIn datetime
    declare @checkOut datetime
    set @checkDay = @begin
    while (@checkDay<[email protected]) begin
    set @checkIn = convert(varchar(10),@checkDay)+' 08:35:00'
    set @checkOut = convert(varchar(10),@checkDay)+' 18:30:00'
    insert into #query_Table_Temp (checkDay,checkIn,checkOut) values(@checkDay,@checkIn,@checkOut)
    --update #query_Table_Temp set isHoliday=1 where checkDay in (select Holiday from OPENQUERY(OAMySQL, 'SELECT * from a_rest_holiday'))
    set @checkDay = dateadd(day,1,@checkDay)
    end
    delete from #query_Table_Temp where checkDay in (select Holiday from OPENQUERY(OAMySQL, 'SELECT * from a_rest_holiday'))--这句引起出错,把这些调用链接服务器的所有语句删除就举出错
    create table #attend_Temp(
    checkDay datetime not null
    ,userID int
    ,Name varchar(30)
    ,User_ID varchar(30)
    ,dept_ID int
    ,defCheckIn datetime
    ,defCheckOut datetime
    ,checkIn datetime null
    ,checkOut datetime null
    ,rest bit not null default 0
    ,leave1 bit not null default 0
    ,leave2 bit not null default 0
    ,out1 bit not null default 0
    ,out2 bit not null default 0
    ,evection bit not null default 0
    )
    insert #attend_Temp (checkDay,userID,Name,User_ID,dept_ID,defCheckIn,defCheckOut)
    select a.checkDay,b.UserID,b.Name,b.oa_UserID,b.defaultDeptID,a.checkIn,a.checkOut from #query_Table_Temp a join FileServiceDB.dbo.UserInfo b on 1=1 where b.Active=1 and b.checkFree=0
    声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
    PHP编程就业班

    相关文章推荐

    • PHP高并发实例详解之解决商品库存超卖问题• 带你聊聊PHP中的泛型之基础知识浅析• 十天学会php之第三天_php基础• 再点一次Active的名,我把你的函数功能扩充了一下,嘻嘻,现在能_PHP• PHP5.0对象模型探索之其它特性_PHP

    全部评论我要评论

  • 取消发布评论发送
  • 1/1

    PHP中文网