Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Backup and restore a table
Message
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Copies de sauvegarde
Divers
Thread ID:
01682994
Message ID:
01683038
Vues:
24
>>>>I do have a PK which is an Identity column. So, I suppose, after I rename the table, I can set the Identity again.
>>>>I will have to test this concept.
>>>>Thank you.
>>>
>>>You can try:
>>>
>>>1. In SSMS right click on the table and select 'Script as create'
>>>2. In that script change names to use new names
>>>3. SET IDENTITY INSERT OFF
>>>4. insert into NewTable (list all columns)
>>> select list All Columns from myTable
>>>
>>>--- This is assuming you don't use some advanced features such as temporal table
>>>
>>>Once you're ready to get back you would also need to use
>>>
>>>DBCC CHECKIDENT ('MyTable', RESEED, MaxCurrentValue);
>>>
>>>(https://stackoverflow.com/questions/21824478/reset-identity-seed-after-deleting-records-in-sql-server)
>>
>>Thank you for the suggestion. I wish the item 4. (above) would accept the "*" instead of listing all fields.
>>I will check this article.
>
>It will (with SET IDENTITY INSERT OFF). I just prefer to be more verbose / explicit.

I see. Thank you.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform