Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Reliably check if a table exists
Message
From
21/05/2007 05:49:35
Walter Nicholls
Cornerstone Software Ltd
Auckland, New Zealand
 
 
To
21/05/2007 00:50:19
General information
Forum:
ASP.NET
Category:
ADO.NET
Environment versions
Environment:
C# 2.0
Database:
MS SQL Server
Miscellaneous
Thread ID:
01227222
Message ID:
01227231
Views:
19
> most reliable method of testing if a table exists?
> ... I am using SQL Server compact edition.

I've only ever seen the kind of technique you've shown. You might get slightly quicker/simpler code by using ExecuteScalar and testing for DBNull.Value.

I know this doesn't help, but in SQL 2000+ I usually use this:
if object_id( 'RiaOrder', 'U' ) is not null 
begin
 .... 
end
Change the second parameter to 'P' for procedures.. see Books Online for more.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform