Tuesday, January 20, 2009

Drop all the tables from a database

To delete all the tables from a database:

Select 'drop table ' + Object_name(object_id) from sys.objects where type = 'U'

(or)

EXEC sp_MSforeachtable @command1 = "DROP TABLE ?"



To Delete All Records from a table:

Select 'delete from ' + Object_name(object_id) from sys.objects where type = 'U'

No comments:

Post a Comment