I've tried looking for a similar question but I could find one, so I'll post one! I'm creating a Java program that drops certain tables for me, MySQL one looks like this:
String[] tablesToDrop = new String[]{tableName,tableName2};
Connection con = DriverManager.getConnection(dbUrl, userName,password);
Statement stmt = con.createStatement();
for (int i = 0; i < tablesToDrop.length; i++) {
System.out.println("Dropping " + tablesToDrop[i] + " Table..");
stmt.executeUpdate("DROP TABLE IF EXISTS " + tablesToDrop[i]);
}
My question is how would this look for SQL Server 2008 version? the stmt.executeUpdate(???); part? I want to drop a table if it exists, getting the table names from an array and passing it into a for loop.