Determine if table exists in SQL Server CE?

Michael Itzoe picture Michael Itzoe · Jan 10, 2009 · Viewed 15.8k times · Source

I know this is similar to this question, but I'm using SQL Server CE 3.5 with a WinForms project in C#. How can I determine whether a table exists? I know the IF keyword is not supported, though EXISTS is. Does information_schema exist in CE where I can query against it? Thanks.

Answer

Mehrdad Afshari picture Mehrdad Afshari · Jan 10, 2009

Yes, it does exist:

SELECT *
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME = 'TableName'