Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Re-create the table, but preserve the data
Message
 
 
À
04/06/2008 12:58:27
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01321355
Message ID:
01321656
Vues:
14
>>>Did you have any constraints of that table?
>>>If not then you could use this (after a really good test of course)
>>>
>>>SELECT * INTO dbo.Tmp_YourTable FROM YourTable
>>>GO
>>>DROP TABLE dbo.YourTable
>>>GO
>>>EXECUTE sp_rename N'dbo.Tmp_YourTable', N'YourTable', 'OBJECT'
>>>GO
>>>
>>
>>Still not exactly clear. I guess I could have tried select *, extra new fields into temptable and then rename...
>>
>>But I do have constraints.
>>
>>Anyway, I have a new more complex question now (sort of interface question), so I'll ask in a new thread.
>
>BTW why you need to DROP table?
>Isn't ALTER TABLE work for you?

Sure ALTER TABLE would work. I wanted to have a CREATE TABLE script so I can send it to other developers here (they didn't have the table yet). But I wanted to preserve my test data.

Anyway, I sent the script yesterday, lost my test data, etc.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform