Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Insert field using Alter Table
Message
 
À
28/10/2007 13:33:59
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9
Divers
Thread ID:
01264579
Message ID:
01264581
Vues:
10
>Dear All,
>
>I want to programmatically insert field into database table after
>specific field.
>Normally Alter Table will add field on the bottom of fields order
>whereas I want to add it let say as 3rd column in table.
>
>Is this possible and how ?
>
>TIA

Not with ALTER TABLE, You could use AFIELDS to get all fields in array insert new array element at 3th position and then create table from that array, append records from all table, delete old table and rename newly created one to old name.
The big question here is why?
One more method:

USE MyOldTable

lcSELECT = [SELECT ]
FOR lnFor = 1 TO FCOUNT()
IF lnFor = 3
lcSELECT = lcSELECT + [ CAST(xxxx AS (desired type)) AS NewField, ]
ENDIF
lcSELECT = lcSELECT + FIELDS(lnFor)+[,]
NEXT
lcSELECT = LEFT(lcSELECT, LEN(lcSELECT)-1) +[ FROM MyOldTable INTO TABLE tmpNewTable]
&lcSELECT

Then again delete old table and rename new one
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