Determine if table exists in SQL Server CE?

后端 未结 3 2013
余生分开走
余生分开走 2021-02-07 06:00

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

3条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-07 06:12

    As an alternative you can Query the Table and catch the Exception thrown. If there is an Exception, the Table wasn't found, else the Table exists.

    SELECT TOP 1 1 FROM TableName;
    

    A little and simple Performance Test had better Results than the Query against INFORMATION_SCHEMA. Although I would consider a Query against INFORMATION_SCHEMA as cleaner.

提交回复
热议问题