douao3063 2017-04-19 12:57
浏览 20

在PHP + sqlsrv中执行dbcc

I have a script in PHP with sqlsrv, which connects to a SQL Server 2016 database, and executes SQL queries and retrieves results. Up to here, no problem. But if I try to execute a DBCC CHECKIDENT ($Table, RESEED, $NextIdentity) or a BACKUP DATABASE, as soon as the command "prints" something, the function sqlsrv_query returns, and returns FALSE. Example:

sqlsrv_query( "BACKUP DATABASE MYDB TO DISK = 'C:\\Backup\\MYDB.bak'" );    

The sqlsrv_query returns FALSE, and sqlsrv_errors contains:

Array
(
    [0] => Array
        (
            [0] => 01000
            [SQLSTATE] => 01000
            [1] => 3211
            [code] => 3211
            [2] => [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]10 percent processed.
            [message] => [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]10 percent processed.
        )

)

For some DBCC commands, it is possible to use them specifying "WITH TABLERESULTS", which would solve the problem, but the specific DBCC that I need does not support that.

Ideally I would like a solution that is synchronous (for instance, waits the end of the backup before returning) and that allows me to check if the DBCC or BACKUP operation was successful.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度
    • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
    • ¥15 ETLCloud 处理json多层级问题
    • ¥15 matlab中使用gurobi时报错
    • ¥15 这个主板怎么能扩出一两个sata口
    • ¥15 不是,这到底错哪儿了😭
    • ¥15 2020长安杯与连接网探
    • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么