PHP和SQL 2008 - 截断表不起作用

时间:2012-12-17 22:32:04

标签: php sql sql-server-2008

为什么这张桌子被截断了?没有错误返回。如果我在SQL Server Management Studio中运行truncate SQL,它会正常截断。

$truncate = "USE energyDB truncate table temp_energydata";

// Initiate connection to energyDB MS SQL server
    $connection = sqlsrv_connect($serverName, $connectionInfo);

    if( $connection ) {
     echo "Connection established.";
}else{
     echo "Connection could not be established.<br />";
     die( print_r( sqlsrv_errors(), true));
}

    // Start the query on the Database server
    $statement = sqlsrv_query($connection,$truncate);

    if( $statement ) {
     echo "Truncate Query completed.";
}else{
     echo "Query not completed.<br />";
     die( print_r( sqlsrv_errors(), true));

1 个答案:

答案 0 :(得分:0)

@ user1745767

$ truncate =“USE energyDB truncate table [temp_energydata]”;

尝试这样也花了好几个小时才能遇见。