Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How To Copy Records
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
How To Copy Records
Divers
Thread ID:
01119791
Message ID:
01119791
Vues:
51
I need to pull all records from the Column_Headers table below, change the 'type' column to read 'lf_tree'
and then insert them back into the table, so that I will then have 2 sets of records, one with a type
of 'sf_tree' and another with a type of 'lf_tree'

Can I do this in the Query Analyzer?
id  type    field_key  caption    display  sequence width1 width2 align isdefault
--------------------------------------------------------------------------------------------
44  sf_tree airdate    Air Date         1	  1     75     75     0	        1
45  sf_tree airtime    Air Time         1	  2     40     40     0	        1
46  sf_tree progtitl   Program          1	  3    137    137     0	        1
47  sf_tree statname   Station          1	  4    115    115     0	        1
48  sf_tree clientid   Client Id        1	  5     45     45     0	        1
49  sf_tree lmarket    Market           1	  6    120    120     0	        1
50  sf_tree refnum     Ref Num          1	  7     65     65     0	        1
I tried this, but SQL just duplicates the records:
insert into column_headers
 (type, field_key, caption, display, sequence, width1, width2, align, isdefault)
  select type as 'lf_tree',
         field_key,
         caption, 
         display,
         sequence, 
         width1,
         width2,
         align, 
         isdefault
  from column_headers
  where type = 'sf_tree'
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform