2013-03-08 55 views
0

我正在使用mssql_query連接到現有的SQL Server 2008數據庫使用mssql_query更新數據庫時出錯

SELECT querys都OK,但是當我運行UPDATE querys這樣的:

mssql_query("UPDATE TABLENAME SET fieldname = 1 WHERE Pk = '".$pk."'"); 

我得到這個錯誤:

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)

這裏是我的連接代碼數據庫:

$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); 

回答

0

您可能必須通過轉動setti明確更改設置恩格斯。您可以通過UPDATE語句之前發出以下查詢這樣做:

SET 
    ANSI_NULLS, 
    QUOTED_IDENTIFIER, 
    CONCAT_NULL_YIELDS_NULL, 
    ANSI_WARNINGS, 
    ANSI_PADDING 
ON; 

如果有額外的設置產生的錯誤,這些可能要隨之改變。

另請參閱:ANSWER: UPDATE failed because the following SET options have incorrect settings: 'ANSI_NULLS, QUOTED_IDENTIFIER'

+0

謝謝SchmitzIT,解決我的問題。 – carlosduarte 2013-03-08 10:25:56

+0

@carlosduarte - 你最歡迎:) – SchmitzIT 2013-03-08 10:33:03