使用mssql_query更新数据库时出错 [英] Error while updating Database with mssql_query
问题描述
我正在使用mssql_query
连接到现有的 SQL Server 2008数据库.
I'm using mssql_query
to connect to an existing SQL Server 2008 Database.
SELECT
查询还可以,但是当我运行UPDATE
查询时,如下所示:
SELECT
querys are ok, but when I run UPDATE
querys like the following:
mssql_query("UPDATE TABLENAME SET fieldname = 1 WHERE Pk = '".$pk."'");
我收到此错误:
更新失败,因为以下SET选项不正确 设置:'ANSI_NULLS,QUOTED_IDENTIFIER,CONCAT_NULL_YIELDS_NULL, ANSI_WARNINGS,ANSI_PADDING".验证SET选项是否正确 与索引视图和/或计算列上的索引一起使用和/或 过滤的索引和/或查询通知和/或XML数据类型 方法和/或空间索引操作. (严重性16)
UPDATE failed because the following SET options have incorrect settings: 'ANSI_NULLS, QUOTED_IDENTIFIER, 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)
这是我与数据库的连接代码:
Here is my connection code to Database:
$server = 'SRVSQL';
// Connect to MSSQL
$link = mssql_connect($server, 'xx', 'xxxxxx');
if (!$link) {
die('Something went wrong while connecting to MSSQL');
}
$conn = mssql_select_db('xxxxxxx',$link);
推荐答案
您可能必须通过打开设置来显式更改设置.为此,您可以在UPDATE语句之前发出以下查询:
You might have to explicitly change the settings by turning the settings on. You can do so by issuing the following query prior to the UPDATE statement:
SET
ANSI_NULLS,
QUOTED_IDENTIFIER,
CONCAT_NULL_YIELDS_NULL,
ANSI_WARNINGS,
ANSI_PADDING
ON;
如果还有其他设置会产生错误,则可能也需要更改这些设置.
Should there be additional settings yielding errors, those might have to be changed as well.
另请参阅:答案:更新失败是因为以下SET选项的设置有误:'ANSI_NULLS,QUOTED_IDENTIFIER'
这篇关于使用mssql_query更新数据库时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!