I am trying to use sql server using PDO, and I need to use a temporary table.
I am trying following code to create table:
$strSQL = "Create Table #scsemData1
(
StudentID Varchar(14) primary key,
EIIN Varchar(6),
StudentName varchar(100),
FathersName varchar(100)
);";
try
{
$objSTMT = $objDBConn->prepare($strSQL);
$objSTMT->execute();
}
catch(PDOException $e)
{
echo 'SQL failed: ' . "
" . 'Error Message: ' . $e->getMessage() . "
" . 'Error Code: ' . $e->getCode();
$objDBConn= null;
exit("
" . 'err-104');
}
That doesn't throw/show any error.
But when I try to delete that temporary table using code bellow:
$strSQL = "DROP TABLE #scsemData1";
try
{
$objSTMT = $objDBConn->prepare($strSQL);
$objSTMT->execute();
}
catch(PDOException $e)
{
echo "SQL failed: <br> Error Message: " . $e->getMessage() . '<br>Error Code: ' . $e->getCode() . '<br><br>';
$objDBConn= null;
exit('<br>err-104');
}
It shows below error:
Cannot drop the table '#scsemData1', because it does not exist or you do not have permission.