Stored Proc to Find and Drop tables (Dynamic SQL)

General
Enthusiast

Stored Proc to Find and Drop tables (Dynamic SQL)

Hi Folks,

I want to create a Stored Proc wherein I will first find a list of tables to be dropped as :

select tablename from dbc.tables where tablename like '%Test%' and Tablekind = 'T'



and then loop through this list using a cursor and then use dynamic sql to drop these tables. It will also be good to have a parameter in the Stored Proc that accepts the search pattern of the tables required to be dropped.

Can anyone please help ?

Thanks,

Raj