Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Easy way to duplicate record
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
00468284
Message ID:
00470499
Vues:
39
>I want to copy a record from a table to another record of the same table with a new primary key identity column value of course.
>
>The problem is that the table has 162 fields, so listing all fields and building a sql statement with all the right commas and quotation marks is tedious.
>
>I tried:
>insert T1 select * from T1 where id=7008
>,but it is trying to overwrite the identity then and errs.
>
>If only there was a *-1 specification which meant all fields, but the first.
>
>Any ideas on this?
-------------------------------------------------------
I haven't been able to find a solution either, so I had to list all the fields. I did use the DTS wizard however, selected the table and fields to export and had a list of fields generated in one of the steps by the wizard. A simple copy-and-paste into my code solved the problem of typing all fields.

This however does not work, if your table structure changes. Good ol' VFP has the commands:

SCATTER MEMVAR
RELEASE ID
INSERT INTO ..
GATHER MEMVAR

I wish someone could suggest something similar for SQL.
Aristotle
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform