I need to delete all tables which name has the pattern '%-%-%-%-%'. The best way to do it I found so far is to do it in 2 steps:
Generate the deletion request as by calling the request below
SELECT ' DROP TABLE ' + REPLACE(TABLE_NAME, '-', NCHAR(8211)) FROM information_schema.tables where TABLE_NAME like '%-%-%-%-%' ORDER BY TABLE_NAME
Run the deletion request.
Unfortunately step 2. does not work. Even if I REPLACE(TABLE_NAME, '-', NCHAR(8211)), I still get Msg 102, Level 15, State 1, Line 1 Incorrect syntax near '0'. etc.; 0 appreas in the message because the first line of deletion request is DROP TABLE 0df78d48–c718–49be–ab55–5f158ebdd64c–results.
Could you help? Thanks!
Placing square brackets around the table names should give you the result you want.
Example:
DROP TABLE [0df78d48–c718–49be–ab55–5f158ebdd64c–results]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With