If you are looking for something like you can do with SQL server: IF NOT EXISTS (...
, unfortunately, this is not possible with SQL Server Compact (the T-SQL IF
is not supported). See SQL Reference (SQL Server Compact).
Based on this thread, you can do something like this:
select * from Information_SCHEMA.columns
where Table_name='audit' and column_name='new_key'
(ie no result = does not exist).
Also note that batch queries are not supported in SQL Server Compact at all. So you can't check if the column exists and add the column if needed in the same SQL statement.
Or if you are looking for a snippet that you can use with VB.NET or C#, take a look at this SO question: How can I determine whether a column exists in a SQL Server CE table with C#?