Skip to content
Advertisement

Delete row if table exists SQL

I have a script that drops a load of tables using DROP TABLE IF EXISTS, this works.

There is also a delete in this script to DELETE a row from another table that I do not manage. This table may or may not exist.Is there any to check the table exists before attempting to delete a row?

this needs to work for MYSQL and SQLServer

thanks Alex

Advertisement

Answer

To check in SQL SERVER,

To check in mysql:

You simply count:

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement