Incorrect syntax near the keyword 'if' SQL Command

Viewed 33

I am not sure what I am doing wrong but I get the error : Incorrect syntax near the key word 'if'. This is the code that is giving me issues. I want to create a database and if it doesn't exists. What am I doing wrong?

   connection.Open();
   var dbCommand = connection.CreateCommand();
   dbCommand.CommandText = "CREATE DATABASE if not exists StockNotesDB;";
   dbCommand.ExecuteNonQuery();```
0 Answers
Related