dongtang1997 2011-08-31 20:19
浏览 46
已采纳

MSSQL标量值函数+ PHP

first post/question here. I'm attempting to access a scalar-valued function in PHP using the following query:

select *, dbo.fnFunctionName_asArray(AnID,';') as refRes FROM ResourceDB where UniqueID = 'IDgoesHere'

This query runs perfectly fine within MS SQL Server Management Studio but when trying to run the query via PHP I get a horrendous error.

Here is the PHP code itself:

$sql_r = "select *, dbo.fnFunctionName_asArray(AnID,';') as refRes FROM ResourceDB where UniqueID = 'IDgoesHere'";
$r_r = mssql_query($sql_r, $msdbc);

And the error is as follows:

Warning: mssql_query() [function.mssql-query]: message: SELECT failed because the following SET options have incorrect settings: 'CONCAT_NULL_YIELDS_NULL, ANSI_WARNINGS, ANSI_PADDING'. Verify that SET options are correct for use with indexed views and/or indexes on computed columns and/or filtered indexes and/or query notifications and/or XML data type methods and/or spatial index operations. (severity 16) in

I've searched far and wide and have found information on stored procedures, but not on functions within MSSQL. I'm not sure how to interpret the error message as well.

Thanks in advance.

  • 写回答

1条回答 默认 最新

  • doukuizuo1795 2011-08-31 20:42
    关注

    the error message is the key:

    Warning: mssql_query() [function.mssql-query]: message: SELECT failed because the following SET options have incorrect settings: 'CONCAT_NULL_YIELDS_NULL, ANSI_WARNINGS, ANSI_PADDING'. Verify that SET options are correct for use with indexed views and/or indexes on computed columns and/or filtered indexes and/or query notifications and/or XML data type methods and/or spatial index operations. (severity 16) in

    when trying to use certain features, SQL Server is picky about your connection settings.

    you are connecting to SQL Server with different settings for SSMS and your php program. Their defaults must be different. Run this SQL command from SSMS and then from within php:

    DBCC USEROPTIONS 
    

    it will show your actual settings, which are different. Try using these settings:

    SET ANSI_NULLS ON 
    SET CURSOR_CLOSE_ON_COMMIT ON 
    SET ANSI_NULL_DFLT_ON ON 
    SET ANSI_PADDING ON 
    SET QUOTED_IDENTIFIER ON 
    SET ANSI_WARNINGS ON 
    SET ARITHABORT ON 
    SET CONCAT_NULL_YIELDS_NULL ON 
    SET NUMERIC_ROUNDABORT OFF
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况
  • ¥60 SOL语句中Where查询中的 from to 语句能不能从小到大换成从大到小(标签-SQL)
  • ¥15 画两个图 python或R
  • ¥15 在线请求openmv与pixhawk 实现实时目标跟踪的具体通讯方法
  • ¥15 八路抢答器设计出现故障
  • ¥15 请教一下c语言的代码里有一个地方不懂
  • ¥15 opencv 无法读取视频
  • ¥15 用matlab 实现通信仿真
  • ¥15 按键修改电子时钟,C51单片机
  • ¥60 Java中实现如何实现张量类,并用于图像处理(不运用其他科学计算库和图像处理库))