As the title might have explained, i have a php project here.
Inside i use PDO to connect to my database. At first PHP was connected to a MySQL-Database
. But now things have changed and I use a MsSQL-Database
.
In MySQL you can easily do the following:
DROP DATABASE IF EXISTS mydatabase;
How can this be achieved with a MsSQL Database
?
I have tried to do something like this:
IF EXISTS(select * from sys.databases where name='mydatabase')
DROP DATABASE mydatabase
When i do so i get the following error
Doctrine\DBAL\Driver\PDOException: SQLSTATE[42S22]: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Ungültiger Spaltenname 'mydatabase'.
But it doesnt work. It think this is related to the fact, that a PDO
Connection is tied to a specific database and in my case i create a connection to database called mydatabase
.
Im thankful for every hint you can give me.
Max