Following the guidelines presented in SO Question #167576, I constructed the following SQL query string in my C# WinForm application to determine if table RMCoil
exists:
using (SqlCeCommand cmd = new SqlCeCommand(null, new SqlCeConnection(Connection))) {
cmd.Connection.Open();
cmd.CommandText =
"IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='RMCoil') " +
"SELECT 1 ELSE SELECT 0";
if (cmd.ExecuteNonQuery() < 1) {
// code to create table
}
}
Executing the non query throws this SqlCeException
:
There was an error parsing the query. [ Token line number = 1,Token line offset = 1,Token in error = IF ]
I'm fairly new to SqlCeServer. Could someone enlighten me on how to execute this query all in one line?