Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Removing all tables
Message
From
29/02/2008 11:49:42
 
General information
Forum:
Microsoft SQL Server
Category:
Other
Miscellaneous
Thread ID:
01297747
Message ID:
01297771
Views:
16
>
>*** INFORMATION_SCHEMA version
>USE YourDataBase
>DECLARE @TableName AS varchar(8000)
>DECLARE @sql       AS varchar(8000)
>SELECT @TableName = MIN(Table_Name) FROM INFORMATION_SCHEMA.Tables WHERE TABLE_TYPE = 'BASE TABLE'
>WHILE @TableName IS NOT NULL
>      BEGIN
>          SET @sql = 'DROP TABLE '+@TableName
>          EXEC (@sql)
>          SELECT @TableName = MIN(Table_Name) FROM INFORMATION_SCHEMA.Tables WHERE Table_Name > @TableName AND TABLE_TYPE = 'BASE TABLE'
>      END
>
>
>*** sys.Tables version
>USE YourDataBase
>DECLARE @TableName AS varchar(8000)
>DECLARE @sql       AS varchar(8000)
>SELECT @TableName = MIN(Name) FROM sys.Tables WHERE Type_Desc = 'USER_TABLE'
>WHILE @TableName IS NOT NULL
>      BEGIN
>          SET @sql = 'DROP TABLE '+@TableName
>          EXEC (@sql)
>          SELECT @TableName = MIN(Name) FROM sys.Tables WHERE Name > @TableName AND Type_Desc = 'USER_TABLE'
>      END
>
Thanks
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Reply
Map
View

Click here to load this message in the networking platform