Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Removing all tables
Message
 
À
29/02/2008 11:23:51
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Divers
Thread ID:
01297747
Message ID:
01297753
Vues:
18
>>
>>USE YourDataBase
>>DECLARE @TableName AS varchar(8000)
>>DECLARE @sql       AS varchar(8000)
>>SELECT @TableName = MIN(Table_Name) FROM INFORMATION_SCHEMA.Tables
>>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
>>      END
>>
>
>I see you already have some code for that. :)
>
>But, when I run it, I have:
>
>"Invalid object name 'INFORMATION_SCHEMA.Tables'."

You have no sp_MsForEachTable no INFORMATION_SCHEMA.Tables?
There is something wrong with installation then.
This is View with is created for each Database
Could you post your test script?
That View EXISTS in ALL versions since SQL Server 2000


What is the result of SELECT * FROM sys.Tables (this is another view but it is in SQL Server 2005 only, I think)?

If you have sys.Tables the the code could be modified:
><pre>
USE YourDataBase
DECLARE @TableName AS varchar(8000)
DECLARE @sql       AS varchar(8000)
SELECT @TableName = MIN(Name) FROM sys.Tables
WHILE @TableName IS NOT NULL
      BEGIN
          SET @sql = 'DROP TABLE '+@TableName
          EXEC (@sql)
          SELECT @TableName = MIN(Name) FROM sys.Tables WHERE Name > @TableName
      END
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform