Checking if table exists
843854Aug 21 2002 — edited Aug 21 2002I found a query on 4GuysFromRolla to check if a table exists on SQL Server 2000, and then execute a query. Here's my code:
String sql_query = "if EXISTS (select * from INFORMATION_SCHEMA.tables where table_name = '" + table_name + "') Select * from " + table_name;
ResultSet rs = stmt.executeQuery(sql_query);
while (rs.next()) {
....
}
Now I know for a fact that the table doesn't exist, but instead of getting nothing, I get a "No ResultSet was produced" error. Is there any way around this?
Dan