Dropping multiple tables?
-
Hi again I want to drop multiple tables from my database starting with the same name. I've tried this:
SQLcommand = "DROP TABLE WHERE TABLE LIKE = 'a" + identity + "%'";
SqlCeCommand sucuk = new SqlCeCommand(SQLcommand, conn);
sucuk.ExecuteNonQuery();but it didn't work My tables start with an "a", and follows by an identity number, then a "year" I want to drop all the tables with the same identity, what can be the suitable solution can anybody help me please :( ?
-
Hi again I want to drop multiple tables from my database starting with the same name. I've tried this:
SQLcommand = "DROP TABLE WHERE TABLE LIKE = 'a" + identity + "%'";
SqlCeCommand sucuk = new SqlCeCommand(SQLcommand, conn);
sucuk.ExecuteNonQuery();but it didn't work My tables start with an "a", and follows by an identity number, then a "year" I want to drop all the tables with the same identity, what can be the suitable solution can anybody help me please :( ?
Hi, why don't you look it up in the documentation? just type SQL and the keywords into Google. e.g. DROP TABLE in SQL[^], as you can see there is no WHERE clause. However in MySQL one can do "SHOW TABLES LIKE 'a%'" :)
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
-
Hi, why don't you look it up in the documentation? just type SQL and the keywords into Google. e.g. DROP TABLE in SQL[^], as you can see there is no WHERE clause. However in MySQL one can do "SHOW TABLES LIKE 'a%'" :)
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
ahah yeah you're right I've tried it and a few guys like me tried this WHERE clause I couldn't find a proper syntax for C# to drop multiple tables How can I use this "SHOW" ?
-
ahah yeah you're right I've tried it and a few guys like me tried this WHERE clause I couldn't find a proper syntax for C# to drop multiple tables How can I use this "SHOW" ?
Emmet_Brown wrote:
I couldn't find a proper syntax for C# to drop multiple tables
There is no direct relation to C#, whatever programming language you choose, in the end you are sending strings of SQL commands.
Emmet_Brown wrote:
How can I use this "SHOW" ?
I have already told you its all in the documentation, i.e. one Google search away. I suggest you get your act together. :)
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
-
Hi again I want to drop multiple tables from my database starting with the same name. I've tried this:
SQLcommand = "DROP TABLE WHERE TABLE LIKE = 'a" + identity + "%'";
SqlCeCommand sucuk = new SqlCeCommand(SQLcommand, conn);
sucuk.ExecuteNonQuery();but it didn't work My tables start with an "a", and follows by an identity number, then a "year" I want to drop all the tables with the same identity, what can be the suitable solution can anybody help me please :( ?
Take it to the General Database forum.
-
ahah yeah you're right I've tried it and a few guys like me tried this WHERE clause I couldn't find a proper syntax for C# to drop multiple tables How can I use this "SHOW" ?
You can query sysobjects to find out which tables match your pattern. Then you have to issue a DROP TABLE command for each of them. As pointed out, this belongs more to the Database forum.
Cheers, Vikram. (Cracked not one CCC, but two!)
-
Hi again I want to drop multiple tables from my database starting with the same name. I've tried this:
SQLcommand = "DROP TABLE WHERE TABLE LIKE = 'a" + identity + "%'";
SqlCeCommand sucuk = new SqlCeCommand(SQLcommand, conn);
sucuk.ExecuteNonQuery();but it didn't work My tables start with an "a", and follows by an identity number, then a "year" I want to drop all the tables with the same identity, what can be the suitable solution can anybody help me please :( ?