Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine if table exists in SQL Server CE?

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.

like image 697
Michael Itzoe Avatar asked Jan 10 '09 18:01

Michael Itzoe


People also ask

How do you check if a table exist in SQL Server?

To check if a table exists in SQL Server, you can use the INFORMATION_SCHEMA. TABLES table. You can use this table with an IF THEN clause do determine how your query responds whether or not a table exists.

How do you check whether the table is exist or not?

To check if table exists in a database you need to use a Select statement on the information schema TABLES or you can use the metadata function OBJECT_ID(). The INFORMATION_SCHEMA. TABLES returns one row for each table in the current database.


1 Answers

Yes, it does exist:

SELECT *
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME = 'TableName'
like image 122
mmx Avatar answered Oct 09 '22 15:10

mmx